No need to look at the relation size everytime rescanning a relation with
authorPavan Deolasee <[email protected]>
Mon, 11 Jul 2016 07:07:11 +0000 (12:37 +0530)
committerPavan Deolasee <[email protected]>
Mon, 11 Jul 2016 07:07:11 +0000 (12:37 +0530)
sequence scan

This can provide big boost to performance when the inner side of a nested loop
has a sequence scan with large number of rows in outer relation

src/backend/access/heap/heapam.c

index 06a2b1a039104d17342e28f198f2a93746ef7de0..90bc0d78f0cf0b0506544d36db62c127e45cc2c9 100644 (file)
@@ -229,7 +229,8 @@ initscan(HeapScanDesc scan, ScanKey key, bool keep_startblock)
         * results for a non-MVCC snapshot, the caller must hold some higher-level
         * lock that ensures the interesting tuple(s) won't change.)
         */
-       scan->rs_nblocks = RelationGetNumberOfBlocks(scan->rs_rd);
+       if (!keep_startblock)
+               scan->rs_nblocks = RelationGetNumberOfBlocks(scan->rs_rd);
 
        /*
         * If the table is large relative to NBuffers, use a bulk-read access