timescaledb/src/estimate.h
Erik Nordström 9a29f0436d Expose a function cache for query optimizations
A number of TimescaleDB query optimizations involve operations on
functions. This refactor exposes a function cache that can be used to
quickly identify important functions and get access to relevant
auxiliary functionality and/or information. In particular, certain
functions apply to some type of (time) bucketing expression, e.g.,
expressions involving our own `time_bucket` function or PostgreSQL's
`date_trunc`.

This change recognizes the importance of time bucketing and uses the
function cache to access custom functionality around time bucketing
used in query optimizations. For example, both grouping estimates for
hash aggregates and sort transforms can be quickly accessed to make
better use of indexes when bucketing on a time column.

This refactor is also done with anticipation that this will be useful
going forward when other types of optimizations are implemented on
time bucketing expressions, or other functions that can benefit from
this cache.
2019-06-24 10:26:15 +02:00

19 lines
572 B
C

/*
* This file and its contents are licensed under the Apache License 2.0.
* Please see the included NOTICE for copyright information and
* LICENSE-APACHE for a copy of the license.
*/
#ifndef TIMESCALEDB_ESTIMATE_H
#define TIMESCALEDB_ESTIMATE_H
#include <postgres.h>
#define INVALID_ESTIMATE (-1)
#define IS_VALID_ESTIMATE(est) ((est) >= 0)
extern double ts_estimate_group_expr_interval(PlannerInfo *root, Expr *expr,
double interval_period);
extern double ts_estimate_group(PlannerInfo *root, double path_rows);
#endif /* TIMESCALEDB_ESTIMATE_H */