Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitbc843d3

Browse files
committed
First cut at planner support for bitmap index scans. Lots to do yet,
but the code is basically working. Along the way, rewrite the entireapproach to processing OR index conditions, and make it work in joincases for the first time ever. orindxpath.c is now basically obsolete,but I left it in for the time being to allow easy comparison testingagainst the old implementation.
1 parentccbb07d commitbc843d3

File tree

22 files changed

+1015
-586
lines changed

22 files changed

+1015
-586
lines changed

‎src/backend/commands/explain.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1994-5, Regents of the University of California
88
*
99
* IDENTIFICATION
10-
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.133 2005/04/19 22:35:10 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/commands/explain.c,v 1.134 2005/04/22 21:58:31 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -847,9 +847,14 @@ explain_outNode(StringInfo str,
847847
for (i=0;i<indent;i++)
848848
appendStringInfo(str," ");
849849
appendStringInfo(str," -> ");
850+
/*
851+
* Ordinarily we don't pass down our own outer_plan value to our
852+
* child nodes, but in bitmap scan trees we must, since the bottom
853+
* BitmapIndexScan nodes may have outer references.
854+
*/
850855
explain_outNode(str,outerPlan(plan),
851856
outerPlanState(planstate),
852-
NULL,
857+
IsA(plan,BitmapHeapScan) ?outer_plan :NULL,
853858
indent+3,es);
854859
}
855860

@@ -907,7 +912,7 @@ explain_outNode(StringInfo str,
907912

908913
explain_outNode(str,subnode,
909914
bitmapandstate->bitmapplans[j],
910-
NULL,
915+
outer_plan,/* pass down same outer plan */
911916
indent+3,es);
912917
j++;
913918
}
@@ -931,7 +936,7 @@ explain_outNode(StringInfo str,
931936

932937
explain_outNode(str,subnode,
933938
bitmaporstate->bitmapplans[j],
934-
NULL,
939+
outer_plan,/* pass down same outer plan */
935940
indent+3,es);
936941
j++;
937942
}

‎src/backend/executor/nodeBitmapIndexscan.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.2 2005/04/20 15:48:36 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/executor/nodeBitmapIndexscan.c,v 1.3 2005/04/22 21:58:31 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -492,7 +492,8 @@ ExecInitBitmapIndexScan(BitmapIndexScan *node, EState *estate)
492492
indexstate->biss_RuntimeKeyInfo=NULL;
493493
indexstate->biss_RuntimeContext=NULL;
494494
/* Get rid of the speculatively-allocated flag array, too */
495-
pfree(runtimeKeyInfo);
495+
if (runtimeKeyInfo)
496+
pfree(runtimeKeyInfo);
496497
}
497498

498499
/*

‎src/backend/optimizer/path/costsize.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* Portions Copyright (c) 1994, Regents of the University of California
5050
*
5151
* IDENTIFICATION
52-
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.144 2005/04/21 19:18:12 tgl Exp $
52+
* $PostgreSQL: pgsql/src/backend/optimizer/path/costsize.c,v 1.145 2005/04/22 21:58:31 tgl Exp $
5353
*
5454
*-------------------------------------------------------------------------
5555
*/
@@ -104,7 +104,6 @@ boolenable_hashjoin = true;
104104

105105

106106
staticboolcost_qual_eval_walker(Node*node,QualCost*total);
107-
staticvoidcost_bitmap_tree_node(Path*path,Cost*cost,Selectivity*selec);
108107
staticSelectivityapprox_selectivity(Query*root,List*quals,
109108
JoinTypejointype);
110109
staticSelectivityjoin_in_selectivity(JoinPath*path,Query*root);
@@ -474,8 +473,11 @@ cost_bitmap_heap_scan(Path *path, Query *root, RelOptInfo *baserel,
474473
* For lack of a better idea, interpolate like this to determine the
475474
* cost per page.
476475
*/
477-
cost_per_page=random_page_cost-
478-
(random_page_cost-1.0)*sqrt(pages_fetched /T);
476+
if (pages_fetched >=2.0)
477+
cost_per_page=random_page_cost-
478+
(random_page_cost-1.0)*sqrt(pages_fetched /T);
479+
else
480+
cost_per_page=random_page_cost;
479481

480482
run_cost+=pages_fetched*cost_per_page;
481483

@@ -500,7 +502,7 @@ cost_bitmap_heap_scan(Path *path, Query *root, RelOptInfo *baserel,
500502
* cost_bitmap_tree_node
501503
*Extract cost and selectivity from a bitmap tree node (index/and/or)
502504
*/
503-
staticvoid
505+
void
504506
cost_bitmap_tree_node(Path*path,Cost*cost,Selectivity*selec)
505507
{
506508
if (IsA(path,IndexPath))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp