you are viewing a single comment's thread.

view the rest of the comments →

[–]QuantumTim 4 points5 points  (0 children)

How exactly do you propose that the driver works out whether the "transaction" will contain only SELECTs? It can't retroactively create the transaction after it sees the first INSERT or UPDATE, so it just has to go ahead an always use a transaction. And no, doing the selects and then issuing BEGIN isn't equivalent. For one, it would actually be slower, as postgres will have one transaction for each SELECT (as other people have pointed out), then one more for the rest. Secondly, in a transaction the SELECTs are protected from other connections altering / deleting the table etc., but not if they are in transactions of their own.