diff options
author | Robert Haas | 2015-10-16 21:25:02 +0000 |
---|---|---|
committer | Robert Haas | 2015-10-16 21:33:18 +0000 |
commit | ee7ca559fcf404f9a3bd99da85c8f4ea9fbc2e92 (patch) | |
tree | c7507915e9a636a091aa12cfda1643bd85fee8a4 /src/include/access/relscan.h | |
parent | b0b0d84b3d663a148022e900ebfc164284a95f55 (diff) |
Add a C API for parallel heap scans.
Using this API, one backend can set up a ParallelHeapScanDesc to
which multiple backends can then attach. Each tuple in the relation
will be returned to exactly one of the scanning backends. Only
forward scans are supported, and rescans must be carefully
coordinated.
This is not exposed to the planner or executor yet.
The original version of this code was written by me. Amit Kapila
reviewed it, tested it, and improved it, including adding support for
synchronized scans, per review comments from Jeff Davis. Extensive
testing of this and related patches was performed by Haribabu Kommi.
Final cleanup of this patch by me.
Diffstat (limited to 'src/include/access/relscan.h')
-rw-r--r-- | src/include/access/relscan.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 6e6231971fd..356c7e6b048 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -20,6 +20,25 @@ #include "access/itup.h" #include "access/tupdesc.h" +/* + * Shared state for parallel heap scan. + * + * Each backend participating in a parallel heap scan has its own + * HeapScanDesc in backend-private memory, and those objects all contain + * a pointer to this structure. The information here must be sufficient + * to properly initialize each new HeapScanDesc as workers join the scan, + * and it must act as a font of block numbers for those workers. + */ +typedef struct ParallelHeapScanDescData +{ + Oid phs_relid; /* OID of relation to scan */ + bool phs_syncscan; /* report location to syncscan logic? */ + BlockNumber phs_nblocks; /* # blocks in relation at start of scan */ + slock_t phs_mutex; /* mutual exclusion for block number fields */ + BlockNumber phs_startblock; /* starting block number */ + BlockNumber phs_cblock; /* current block number */ + char phs_snapshot_data[FLEXIBLE_ARRAY_MEMBER]; +} ParallelHeapScanDescData; typedef struct HeapScanDescData { @@ -49,6 +68,7 @@ typedef struct HeapScanDescData BlockNumber rs_cblock; /* current block # in scan, if any */ Buffer rs_cbuf; /* current buffer in scan, if any */ /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */ + ParallelHeapScanDesc rs_parallel; /* parallel scan information */ /* these fields only used in page-at-a-time mode and for bitmap scans */ int rs_cindex; /* current tuple's index in vistuples */ |