Are PDO transcations intended just for UPDATE, INSERT and DELETE or can you achieve performance gains if you use a transaction for mulitple SELECT queries?
Are PDO transcations intended just for UPDATE, INSERT and DELETE or can you achieve
Share
From a purist point of view, it would be wrong to use a transaction on SELECT statements ‘to improve performance’. Use a transaction to be sure to not get inconsistencies in the data.
From a performance point of view, locking the tables so no other statement can access it in order to speed up your SELECTs might work – but there are probably better solutions than that. For example, use the
HIGH_PRIORITYattribute in your SELECT statement:This way you use the appropriate method to reach the goal, instead of some hack about which other developers (or even a future you) will wonder why it exists.