Multiple call of GetTransactionSnapshot in single flow - Mailing list pgsql-hackers

From Rajeev rastogi
Subject Multiple call of GetTransactionSnapshot in single flow
Date
Msg-id BF2827DCCE55594C8D7A8F7FFD3AB77158E6129F@SZXEML508-MBX.china.huawei.com
Whole thread Raw
Responses Re: Multiple call of GetTransactionSnapshot in single flow
List pgsql-hackers

I have observed  in some places like exec_bind_message  and exec_simple_query,

Though these two function have already got snapshot but before they call function PortalStart,

current snapshot gets popped off and then they pass InvalidSnapshot  as parameter

because of which inside PortalStart again snapshot is taken.

 

In cases where many transactions are running, taking snapshot multiple times may be very costly.

 

What is the reason for taking snapshot multiple time:

1.       Is this implementation to make sure snapshot is at more granular level ?

2.       Is it something do with current command id of the snapshot?

3.       Or there is any other specific reason for this, which I am not able visualize?

4.       Or am I missing something else?

 

If it is just reason 1, then maybe we can try to pass the same snapshot to PortalStart as taken in caller, it can enhance the performance in many case.

With this change, I  did one small performance test on pgbench with “prepared queries for pgbench select with 16 users and observed performance benefit of 10%”.

 

Please provide your opinion?

 

Thanks and Regards,

Kumar Rajeev Rastogi

 

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: psql \watch always ignores \pset null
Next
From: Etsuro Fujita
Date:
Subject: Re: inherit support for foreign tables