I need to take a snapshot (SELECT) of some table rows for display. These rows will never be modified or deleted in that same transaction, or transmitted to another transaction which could modify those rows. I only want a simple snapshot-like read in a Postgresql function.
For example:
SELECT * FROM "my_table" WHERE "amount" < 1000;
I was thinking about setting the READ COMMITTED transaction level in my Postgresql function:
SET TRANSACTION ISOLATION LEVEL READ COMMITTED;
Will this make sure I won't ever face an exception with my SELECT, no matter if other heavy and complex transactions are running simultaneously? I believe that yes, but I am not a Postgresql expert.
UPDATE:
After doing more reading, I am wondering whether this could to the trick too?
SET TRANSACTION ISOLATION LEVEL READ ONLY DEFERRABLE