From: | Andy Fan <zhihui(dot)fan1213(at)gmail(dot)com> |
---|---|
To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | RelationGetNumberOfBlocks is called every time of heap_rescan. |
Date: | 2020-10-14 12:02:29 |
Message-ID: | CAKU4AWoB5CMc5+c+6sFK+y0Jd=xF_T7OqzKVq087ZM_k8iwE5g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
As for the initscan, It looks to me that the codes and comments
don't match (obviously I'm wrong, this is why I'm asking).
/*
* Determine the number of blocks we have to scan.
*
* It is sufficient to do this once at scan start, since any tuples
added
* while the scan is in progress will be invisible to my snapshot
anyway.
Andy : I can understand until this.
* That is not true when using a non-MVCC snapshot. However, we couldn't
* guarantee to return tuples added after scan start anyway,
Andy: For any isolation level rather than "READ Committed", we should not
read that, for "READ UNCommitted", we can still do the same. So I think
I can understand it here.
* since they
* might go into pages we already scanned. To guarantee consistent
* results for a non-MVCC snapshot, the caller must hold some
higher-level
* lock that ensures the interesting tuple(s) won't change.)
*/
Andy: I can't understand what the "To guarantee consistent results for a
non-MVCC snapshot" mean. Looks something need to be handled
differently for non-MVCC snapshot. Until now I think we CAN Determine
the number of blocks only once for MVCC snapshot which should be
very common.
if (scan->rs_parallel != NULL)
scan->rs_nblocks = scan->rs_parallel->phs_nblocks;
else
scan->rs_nblocks = RelationGetNumberOfBlocks(scan->rs_rd);
Andy: However I see the code checks the number of blocks at every
rescan regardless of snapshot type which I can't understand.
This behavior doesn't cause any troubles to me (I may care about this
for Index Scan, but looks IndexScan doesn't need to do that), So I am
asking just for education purposes. Thanks!
--
Best Regards
Andy Fan
From | Date | Subject | |
---|---|---|---|
Next Message | Julien Rouhaud | 2020-10-14 12:25:00 | Re: Feature improvement: can we add queryId for pg_catalog.pg_stat_activity view? |
Previous Message | Bharath Rupireddy | 2020-10-14 11:35:07 | Re: Parallel copy |