2016-04-01 21:42:24 +08:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* blcost.c
|
|
|
|
* Cost estimate function for bloom indexes.
|
|
|
|
*
|
2019-01-03 01:44:25 +08:00
|
|
|
* Copyright (c) 2016-2019, PostgreSQL Global Development Group
|
2016-04-01 21:42:24 +08:00
|
|
|
*
|
|
|
|
* IDENTIFICATION
|
|
|
|
* contrib/bloom/blcost.c
|
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#include "postgres.h"
|
|
|
|
|
|
|
|
#include "fmgr.h"
|
|
|
|
#include "utils/selfuncs.h"
|
|
|
|
|
|
|
|
#include "bloom.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Estimate cost of bloom index scan.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
|
|
|
|
Cost *indexStartupCost, Cost *indexTotalCost,
|
2017-02-16 02:53:24 +08:00
|
|
|
Selectivity *indexSelectivity, double *indexCorrelation,
|
|
|
|
double *indexPages)
|
2016-04-01 21:42:24 +08:00
|
|
|
{
|
|
|
|
IndexOptInfo *index = path->indexinfo;
|
|
|
|
GenericCosts costs;
|
|
|
|
|
|
|
|
MemSet(&costs, 0, sizeof(costs));
|
|
|
|
|
|
|
|
/* We have to visit all index tuples anyway */
|
|
|
|
costs.numIndexTuples = index->tuples;
|
|
|
|
|
|
|
|
/* Use generic estimate */
|
2019-02-16 02:05:19 +08:00
|
|
|
genericcostestimate(root, path, loop_count, &costs);
|
2016-04-01 21:42:24 +08:00
|
|
|
|
|
|
|
*indexStartupCost = costs.indexStartupCost;
|
|
|
|
*indexTotalCost = costs.indexTotalCost;
|
|
|
|
*indexSelectivity = costs.indexSelectivity;
|
|
|
|
*indexCorrelation = costs.indexCorrelation;
|
2017-02-16 02:53:24 +08:00
|
|
|
*indexPages = costs.numIndexPages;
|
2016-04-01 21:42:24 +08:00
|
|
|
}
|