mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
tableam: Move heap specific logic from estimate_rel_size below tableam.
This just moves the table/matview[/toast] determination of relation size to a callback, and uses a copy of the existing logic to implement that callback for heap. It probably would make sense to also move the index specific logic into a callback, so the metapage handling (and probably more) can be index specific. But that's a separate task. Author: Andres Freund Discussion: https://postgr.es/m/20180703070645.wchpu5muyto5n647@alap3.anarazel.de
This commit is contained in:
@@ -491,6 +491,22 @@ typedef struct TableAmRoutine
|
||||
Snapshot snapshot,
|
||||
struct ValidateIndexState *state);
|
||||
|
||||
|
||||
/* ------------------------------------------------------------------------
|
||||
* Planner related functions.
|
||||
* ------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* See table_relation_estimate_size().
|
||||
*
|
||||
* While block oriented, it shouldn't be too hard to for an AM that
|
||||
* doesn't internally use blocks to convert into a usable representation.
|
||||
*/
|
||||
void (*relation_estimate_size) (Relation rel, int32 *attr_widths,
|
||||
BlockNumber *pages, double *tuples,
|
||||
double *allvisfrac);
|
||||
|
||||
} TableAmRoutine;
|
||||
|
||||
|
||||
@@ -1286,6 +1302,25 @@ table_index_validate_scan(Relation heap_rel,
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Planner related functionality
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/*
|
||||
* Estimate the current size of the relation, as an AM specific workhorse for
|
||||
* estimate_rel_size(). Look there for an explanation of the parameters.
|
||||
*/
|
||||
static inline void
|
||||
table_relation_estimate_size(Relation rel, int32 *attr_widths,
|
||||
BlockNumber *pages, double *tuples,
|
||||
double *allvisfrac)
|
||||
{
|
||||
rel->rd_tableam->relation_estimate_size(rel, attr_widths, pages, tuples,
|
||||
allvisfrac);
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
* Functions to make modifications a bit simpler.
|
||||
* ----------------------------------------------------------------------------
|
||||
|
@@ -33,6 +33,7 @@ extern List *infer_arbiter_indexes(PlannerInfo *root);
|
||||
extern void estimate_rel_size(Relation rel, int32 *attr_widths,
|
||||
BlockNumber *pages, double *tuples, double *allvisfrac);
|
||||
|
||||
extern int32 get_rel_data_width(Relation rel, int32 *attr_widths);
|
||||
extern int32 get_relation_data_width(Oid relid, int32 *attr_widths);
|
||||
|
||||
extern bool relation_excluded_by_constraints(PlannerInfo *root,
|
||||
|
Reference in New Issue
Block a user