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

Reply via email to