@ -1664,9 +1664,7 @@ static Path* choose_bitmap_and(PlannerInfo* root, RelOptInfo* rel, List* paths,
|
||||
return pathinfoarray[0]->path;
|
||||
|
||||
/* Sort the surviving paths by index access cost */
|
||||
if (globalPartPaths > 1) {
|
||||
qsort(pathinfoarray, npaths, sizeof(PathClauseUsage*), path_usage_comparator);
|
||||
}
|
||||
qsort(pathinfoarray, npaths, sizeof(PathClauseUsage*), path_usage_comparator);
|
||||
/*
|
||||
* For each surviving index, consider it as an "AND group leader", and see
|
||||
* whether adding on any of the later indexes results in an AND path with
|
||||
|
||||
@ -1304,49 +1304,67 @@ void BitmapHeapPrefetchNext(
|
||||
ADIO_ELSE()
|
||||
{
|
||||
/* prefetch next synchronously */
|
||||
HBktTblScanDesc hpscan = NULL;
|
||||
Oid oldOid = GPIGetCurrPartOid(node->gpi_scan);
|
||||
int2 oldBktId = cbi_get_current_bucketid(node->cbi_scan);
|
||||
Relation oldheap = NULL;
|
||||
|
||||
while (node->prefetch_pages < node->prefetch_target) {
|
||||
TBMIterateResult* tbmpre = tbm_iterate(*prefetch_iterator);
|
||||
Relation prefetchRel = scan->rs_rd;
|
||||
hpscan = (tbm_is_crossbucket(node->tbm) ? (HBktTblScanDesc)node->ss.ss_currentScanDesc : NULL);
|
||||
if (unlikely(tbm_is_crossbucket(tbm) || tbm_is_global(tbm))) {
|
||||
HBktTblScanDesc hpscan = NULL;
|
||||
Oid oldOid = GPIGetCurrPartOid(node->gpi_scan);
|
||||
int2 oldBktId = cbi_get_current_bucketid(node->cbi_scan);
|
||||
Relation oldheap = NULL;
|
||||
|
||||
while (node->prefetch_pages < node->prefetch_target) {
|
||||
TBMIterateResult* tbmpre = tbm_iterate(*prefetch_iterator);
|
||||
Relation prefetchRel = scan->rs_rd;
|
||||
hpscan = (tbm_is_crossbucket(node->tbm) ? (HBktTblScanDesc)node->ss.ss_currentScanDesc : NULL);
|
||||
|
||||
if (tbmpre == NULL) {
|
||||
/* No more pages to prefetch */
|
||||
tbm_end_iterate(*prefetch_iterator);
|
||||
node->prefetch_iterator = *prefetch_iterator = NULL;
|
||||
break;
|
||||
}
|
||||
node->prefetch_pages++;
|
||||
if (tbmpre == NULL) {
|
||||
/* No more pages to prefetch */
|
||||
tbm_end_iterate(*prefetch_iterator);
|
||||
node->prefetch_iterator = *prefetch_iterator = NULL;
|
||||
break;
|
||||
}
|
||||
node->prefetch_pages++;
|
||||
|
||||
prefetchRel = BitmapHeapPrefetchNextTargetHeap(node, tbmpre, prefetchRel);
|
||||
if (prefetchRel == NULL) {
|
||||
tbmpre = NULL;
|
||||
continue;
|
||||
prefetchRel = BitmapHeapPrefetchNextTargetHeap(node, tbmpre, prefetchRel);
|
||||
if (prefetchRel == NULL) {
|
||||
tbmpre = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* For posix_fadvise() we just send the one request */
|
||||
PrefetchBuffer(prefetchRel, MAIN_FORKNUM, tbmpre->blockno);
|
||||
if (RelationIsValid(oldheap) && oldheap != prefetchRel && PointerIsValid(hpscan) &&
|
||||
oldheap != hpscan->currBktRel) {
|
||||
/* release previous bucket fake relation except the current scanning one */
|
||||
bucketCloseRelation(oldheap);
|
||||
/* now oldheap is NULL */
|
||||
}
|
||||
oldheap = prefetchRel;
|
||||
}
|
||||
|
||||
/* For posix_fadvise() we just send the one request */
|
||||
PrefetchBuffer(prefetchRel, MAIN_FORKNUM, tbmpre->blockno);
|
||||
if (RelationIsValid(oldheap) && oldheap != prefetchRel && PointerIsValid(hpscan) &&
|
||||
oldheap != hpscan->currBktRel) {
|
||||
if (RelationIsValid(oldheap) && PointerIsValid(hpscan) && oldheap != hpscan->currBktRel) {
|
||||
/* release previous bucket fake relation except the current scanning one */
|
||||
bucketCloseRelation(oldheap);
|
||||
/* now oldheap is NULL */
|
||||
}
|
||||
oldheap = prefetchRel;
|
||||
}
|
||||
|
||||
if (RelationIsValid(oldheap) && PointerIsValid(hpscan) && oldheap != hpscan->currBktRel) {
|
||||
/* release previous bucket fake relation except the current scanning one */
|
||||
bucketCloseRelation(oldheap);
|
||||
}
|
||||
/* recover old oid after prefetch switch */
|
||||
GPISetCurrPartOid(node->gpi_scan, oldOid);
|
||||
cbi_set_bucketid(node->cbi_scan, oldBktId);
|
||||
} else {
|
||||
while (node->prefetch_pages < node->prefetch_target) {
|
||||
TBMIterateResult* tbmpre = tbm_iterate(*prefetch_iterator);
|
||||
Relation prefetchRel = scan->rs_rd;
|
||||
|
||||
/* recover old oid after prefetch switch */
|
||||
GPISetCurrPartOid(node->gpi_scan, oldOid);
|
||||
cbi_set_bucketid(node->cbi_scan, oldBktId);
|
||||
if (tbmpre == NULL) {
|
||||
/* No more pages to prefetch */
|
||||
tbm_end_iterate(*prefetch_iterator);
|
||||
node->prefetch_iterator = *prefetch_iterator = NULL;
|
||||
break;
|
||||
}
|
||||
node->prefetch_pages++;
|
||||
|
||||
/* For posix_fadvise() we just send the one request */
|
||||
PrefetchBuffer(prefetchRel, MAIN_FORKNUM, tbmpre->blockno);
|
||||
}
|
||||
}
|
||||
}
|
||||
ADIO_END();
|
||||
}
|
||||
|
||||
@ -294,15 +294,15 @@ explain (costs off) SELECT keyword FROM test_part_bitmapand_ginst_btree WHERE ke
|
||||
QUERY PLAN
|
||||
------------------------------------------------------------------------------------
|
||||
Partitioned Bitmap Heap Scan on test_part_bitmapand_ginst_btree
|
||||
Recheck Cond: ((a = 10) AND (keyword @> '''new'''::tsquery))
|
||||
Recheck Cond: ((keyword @> '''new'''::tsquery) AND (a = 10))
|
||||
Selected Partitions: 1
|
||||
-> BitmapAnd
|
||||
-> Partitioned Bitmap Index Scan on test_part_bitmapand_ginst_btree_a_idx
|
||||
Index Cond: (a = 10)
|
||||
Selected Partitions: 1
|
||||
-> Partitioned Bitmap Index Scan on qq
|
||||
Index Cond: (keyword @> '''new'''::tsquery)
|
||||
Selected Partitions: 1
|
||||
-> Partitioned Bitmap Index Scan on test_part_bitmapand_ginst_btree_a_idx
|
||||
Index Cond: (a = 10)
|
||||
Selected Partitions: 1
|
||||
(10 rows)
|
||||
|
||||
SELECT keyword FROM test_part_bitmapand_ginst_btree WHERE keyword @> 'new' and a = 10;
|
||||
|
||||
Reference in New Issue
Block a user