diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-12 05:10:45 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2009-01-12 05:10:45 +0000 |
commit | b7b8f0b6096d2ab6e4f67980d19e478cf6fab629 (patch) | |
tree | b72f9703650b8fb051b516ba369c7cc929309004 /src/backend/storage/buffer/localbuf.c | |
parent | 1a37056a74e273085c39bb88cba48797695c067e (diff) | |
download | postgresql-b7b8f0b6096d2ab6e4f67980d19e478cf6fab629.tar.gz postgresql-b7b8f0b6096d2ab6e4f67980d19e478cf6fab629.zip |
Implement prefetching via posix_fadvise() for bitmap index scans. A new
GUC variable effective_io_concurrency controls how many concurrent block
prefetch requests will be issued.
(The best way to handle this for plain index scans is still under debate,
so that part is not applied yet --- tgl)
Greg Stark
Diffstat (limited to 'src/backend/storage/buffer/localbuf.c')
-rw-r--r-- | src/backend/storage/buffer/localbuf.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 4dd5619f39f..5431419cfe6 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.85 2009/01/01 17:23:47 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.86 2009/01/12 05:10:44 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -53,6 +53,43 @@ static Block GetLocalBufferStorage(void); /* + * LocalPrefetchBuffer - + * initiate asynchronous read of a block of a relation + * + * Do PrefetchBuffer's work for temporary relations. + * No-op if prefetching isn't compiled in. + */ +void +LocalPrefetchBuffer(SMgrRelation smgr, ForkNumber forkNum, + BlockNumber blockNum) +{ +#ifdef USE_PREFETCH + BufferTag newTag; /* identity of requested block */ + LocalBufferLookupEnt *hresult; + + INIT_BUFFERTAG(newTag, smgr->smgr_rnode, forkNum, blockNum); + + /* Initialize local buffers if first request in this session */ + if (LocalBufHash == NULL) + InitLocalBuffers(); + + /* See if the desired buffer already exists */ + hresult = (LocalBufferLookupEnt *) + hash_search(LocalBufHash, (void *) &newTag, HASH_FIND, NULL); + + if (hresult) + { + /* Yes, so nothing to do */ + return; + } + + /* Not in buffers, so initiate prefetch */ + smgrprefetch(smgr, forkNum, blockNum); +#endif /* USE_PREFETCH */ +} + + +/* * LocalBufferAlloc - * Find or create a local buffer for the given page of the given relation. * |