I've been reading up on transactions and table locking for a while and I am still unclear on something and hoping to find clarification here:
So the situation is that I need to insert blocks of entries (say 10 at a time) with each one containing a count of the number of entries before the block was inserted (so rows 51-60 would contain an entry of 50)
Would wrapping the entire process in a transaction be sufficient to guarantee this count in a high IO database?
e.g.
- Start transaction
- select (Count *) on table_a
- insert block of rows on table_a and include count from select
- End transaction
In the above situation can I guarantee that no rows are inserted between the count and the last insert? (Mysql/InnoDB).
Thanks in advance for your help.