When you initiate a Bitcoin transaction, the information is broadcasted to the whole network, after mining nodes receive the information, they will store it in a local pool for some basic validations, such as checking for double spending.
If it’s valid, it will then be moved to the pool of “Unconfirmed Transactions” for processing. If it fails, this transaction, marked as an “Invalid Transaction”, will not be processed.
This means mining nodes are not only competing with their hashing power, but also validating transactions promptly to update their pool of “Unconfirmed Transactions.”
After obtaining the right to update the ledger, miners will take around 1000 transactions from the “Unconfirmed Transactions” pool to process. Sometimes our transaction may not be processed in time, due to an overwhelmingly number of unconfirmed transactions and each block can only record a limited number of transactions.