diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-12 16:00:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-12 16:00:41 +0000 |
commit | 8a4505013d9f19979fa83fced5588311d3b123d2 (patch) | |
tree | 4419e1e1c6bdec09cdafee0865e18e12a9b8a9ea /src/backend/executor/nodeBitmapHeapscan.c | |
parent | 405728f66976729b15dbc95bbbe3dfa147b5106f (diff) | |
download | postgresql-8a4505013d9f19979fa83fced5588311d3b123d2.tar.gz postgresql-8a4505013d9f19979fa83fced5588311d3b123d2.zip |
Tweak order of operations in BitmapHeapNext() to avoid the case of prefetching
the same page we are nanoseconds away from reading for real. There should be
something left to do on the current page before we consider issuing a prefetch.
Diffstat (limited to 'src/backend/executor/nodeBitmapHeapscan.c')
-rw-r--r-- | src/backend/executor/nodeBitmapHeapscan.c | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c index 2ba8b89ee35..b2aad2133c2 100644 --- a/src/backend/executor/nodeBitmapHeapscan.c +++ b/src/backend/executor/nodeBitmapHeapscan.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.33 2009/01/12 05:10:44 tgl Exp $ + * $PostgreSQL: pgsql/src/backend/executor/nodeBitmapHeapscan.c,v 1.34 2009/01/12 16:00:41 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -236,10 +236,22 @@ BitmapHeapNext(BitmapHeapScanState *node) #endif /* USE_PREFETCH */ } + /* + * Out of range? If so, nothing more to look at on this page + */ + if (scan->rs_cindex < 0 || scan->rs_cindex >= scan->rs_ntuples) + { + node->tbmres = tbmres = NULL; + continue; + } + #ifdef USE_PREFETCH /* * We issue prefetch requests *after* fetching the current page * to try to avoid having prefetching interfere with the main I/O. + * Also, this should happen only when we have determined there is + * still something to do on the current page, else we may uselessly + * prefetch the same page we are just about to request for real. */ if (prefetch_iterator) { @@ -261,15 +273,6 @@ BitmapHeapNext(BitmapHeapScanState *node) #endif /* USE_PREFETCH */ /* - * Out of range? If so, nothing more to look at on this page - */ - if (scan->rs_cindex < 0 || scan->rs_cindex >= scan->rs_ntuples) - { - node->tbmres = tbmres = NULL; - continue; - } - - /* * Okay to fetch the tuple */ targoffset = scan->rs_vistuples[scan->rs_cindex]; |