Lesly O
Lesly O

Reputation: 123

What is the difference in executing a single select query in read committed versus repeatable read transaction?

This question is a little spin-off from Refactor functions so they can be used within a CTE.

The question is simple: is there a different in executing a SELECT query in a READ COMMITTED versus a REPEATABLE READ transaction? We assume that no other queries (even 'SELECT' queries) are done in the transaction. So the transaction is only executing one single SELECT query.

Upvotes: 1

Views: 179

Answers (1)

Laurenz Albe
Laurenz Albe

Reputation: 248215

Normally there won't be a difference for a single SELECT statement.

The exception is if the SELECT statement calls user defined functions that themselves issue multiple SQL statements.

In this case, REPEATABLE READ will make all these SQL statements share a single snapshot of the database, while READ COMMITTED will cause each SQL statement to see a different state of the database.

Upvotes: 3

Related Questions