20 Commits

Author SHA1 Message Date
Lakshmi Narayanan Sreethar
9425402264 PG16: Handle removed EquivalenceClass members
PG16 removes the outerjoin_delayed mechanism and
RestrictInfo.nullable_relids.

postgres/postgres@b448f1c8
postgres/postgres@3bef56e1
2023-08-25 12:40:04 +05:30
Alexander Kuzmenkov
313845a882 Enable -Wextra
Our code mostly has warnings about comparison with different
signedness.
2022-10-27 16:06:58 +04:00
Alexander Kuzmenkov
babcc8e9ee Use function oids instead of names when transforming the sort keys
This is more explicit, and looking up the function name each time has a
performance impact.
2021-12-13 15:35:43 +03:00
Joshua Lockerman
647657404e Improve time_bucket_gapfill optimizations
This commit adds the optimizations we do for regular time bucket,
pushing down sort orders to the underlying time column, to time_bucket_gapfill.
This is made slightly more invasive by the fact that time_bucket_gapfill is
marked as VOLATILE (to prevent postgres from moving it in inappropriate ways).
We handle this by time_bucket_gapfill EC as not volatile, and letting the ususal
sort machinery do its job. This should be safe since we've already planned all
the per-relation paths and have installed the appropriate metadata to know we
will gapfill.
2020-05-11 13:40:56 +03:00
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
Sven Klemm
8e86bda9dd Fix sort_transform optimization
The sort transform optimization to enable index usage are only
safe transformations when the modified PathKey is either the last
member of pathkeys or the only member.
2019-02-12 21:45:40 +01:00
Matvey Arye
34edba16a9 Run clang-format on code 2019-02-05 16:55:16 -05:00
Joshua Lockerman
acc41a7712 Update license header
Only have the copyright in the NOTICE. Hopefully
only having to update one place each year will
keep it consistent.
2019-01-03 11:57:51 -05:00
Sven Klemm
92586d8fc9 Fix typos in comments 2018-12-31 18:36:05 +01:00
Joshua Lockerman
9de504f958 Add ts_ prefix to everything in headers
Future proofing: if we ever want to make our functions available  to
others they’d need to be prefixed to prevent name collisions. In
order to avoid having some functions with the ts_ prefix and
others without, we’re adding the prefix to all non-static
functions now.
2018-12-05 14:43:22 -05:00
Sven Klemm
f27c0a3f28 Move int time_bucket functions with offset to C 2018-11-12 22:27:02 +01:00
Joshua Lockerman
d8e41ddaba Add Apache License header to all C files 2018-10-29 13:28:19 -04:00
Matvey Arye
2ec065b538 Fix formatting to comply with pgindent
This PR fixes all the formatting to be inline with the latest version of
pgindent. Since pgindent does not like variables named `type`, those
have been appropriately renamed.
2018-07-11 09:40:29 -04:00
Erik Nordström
b6e2780460 Apply new indentation (pgindent) used in PostgreSQL 10
Source code indentation has been updated in PostgreSQL 10 to fix a
number of issues. This update applies this new indentation to the
entire code base.

The new indentation requires a new version of pg_bsd_indent, which can
be found here:

https://git.postgresql.org/git/pg_bsd_indent.git
2018-01-18 15:19:23 +01:00
Matvey Arye
d2561cc4fd Add ability to partition by a date type 2017-09-07 12:22:03 -04:00
Matvey Arye
48ea4330d5 Run pgindent 2017-05-03 18:18:35 -04:00
Matvey Arye
c3f930f6c8 Add time_bucket functions
Adds functions to bucket timestamps. These functions are more
powerful versions of date_trunc, since they can take arbitrary
intervals.
2017-05-03 15:40:49 -04:00
Robin Thomas
7b2097a975 ran pgindent successfully with local typedefs; ended up correcting
several code style discrepancies from master.
2017-04-29 18:32:07 -04:00
Matvey Arye
83346079d7 Make optimization of date_trunc more general.
Handle case where there is an additional constraint on time.
This makes the pathkeys for the IndexPath incompatible with
upper level ordering. Since we know the appropriate transform
for those pathkeys already, apply it to those paths too.
2017-04-05 16:35:14 -04:00
Matvey Arye
ea0c97d590 Optimize queries with date_trunc in ORDER BY and a LIMIT.
Common time-series rollups are of the form SELECT date_trunc(const,
time) as t, aggregates... GROUP BY t ORDER BY t DESC LIMIT const2.
Previously, Postgres would not optimize such queries because it
could not match date_trunc(const, time) to any indexes on time, since
it has no way to know that a sort on time is always a valid sort on
date_trunc(const, time).

This commit implements this optimization for date_trunc but it could
apply to a wider range of functions, to be implemented later.
2017-04-05 16:35:14 -04:00