PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
blcost.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * blcost.c
4  * Cost estimate function for bloom indexes.
5  *
6  * Copyright (c) 2016-2017, PostgreSQL Global Development Group
7  *
8  * IDENTIFICATION
9  * contrib/bloom/blcost.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 #include "postgres.h"
14 
15 #include "fmgr.h"
16 #include "optimizer/cost.h"
17 #include "utils/selfuncs.h"
18 
19 #include "bloom.h"
20 
21 /*
22  * Estimate cost of bloom index scan.
23  */
24 void
25 blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
26  Cost *indexStartupCost, Cost *indexTotalCost,
27  Selectivity *indexSelectivity, double *indexCorrelation,
28  double *indexPages)
29 {
30  IndexOptInfo *index = path->indexinfo;
31  List *qinfos;
32  GenericCosts costs;
33 
34  /* Do preliminary analysis of indexquals */
35  qinfos = deconstruct_indexquals(path);
36 
37  MemSet(&costs, 0, sizeof(costs));
38 
39  /* We have to visit all index tuples anyway */
40  costs.numIndexTuples = index->tuples;
41 
42  /* Use generic estimate */
43  genericcostestimate(root, path, loop_count, qinfos, &costs);
44 
45  *indexStartupCost = costs.indexStartupCost;
46  *indexTotalCost = costs.indexTotalCost;
47  *indexSelectivity = costs.indexSelectivity;
48  *indexCorrelation = costs.indexCorrelation;
49  *indexPages = costs.numIndexPages;
50 }
Selectivity indexSelectivity
Definition: selfuncs.h:130
IndexOptInfo * indexinfo
Definition: relation.h:1030
#define MemSet(start, val, len)
Definition: c.h:857
double Selectivity
Definition: nodes.h:638
double tuples
Definition: relation.h:636
void blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, Cost *indexStartupCost, Cost *indexTotalCost, Selectivity *indexSelectivity, double *indexCorrelation, double *indexPages)
Definition: blcost.c:25
List * deconstruct_indexquals(IndexPath *path)
Definition: selfuncs.c:6237
Definition: type.h:90
Cost indexTotalCost
Definition: selfuncs.h:129
double indexCorrelation
Definition: selfuncs.h:131
double numIndexTuples
Definition: selfuncs.h:135
Cost indexStartupCost
Definition: selfuncs.h:128
Definition: pg_list.h:45
double Cost
Definition: nodes.h:639
void genericcostestimate(PlannerInfo *root, IndexPath *path, double loop_count, List *qinfos, GenericCosts *costs)
Definition: selfuncs.c:6386
double numIndexPages
Definition: selfuncs.h:134