timescaledb/test/sql/append.sql
Erik Nordström 139fe34022 Implement constraint-aware appends to exclude chunks at execution time
With standard PostgreSQL append plans, planning-time constraint
exclusion does not work if a query expression contains restrictions
that are non-constants (e.g., mutable functions like now()). This
leads to full scans of all chunks (child tables), significantly
increasing query time.

To fix this, we wrap append plans (Append and MergeAppend) in a
ConstraintAwareAppend plan, which excludes child relations at
execution time by pruning the child relations from the regular append
plan. This happens after first constifying the original restriction
clause every time the plan is executed.

This optimization only happens if there are non-constant restrictions
in the original query and the entire optimization can be disbled with
a GUC variable.
2017-08-19 10:51:10 +02:00

3 lines
54 B
SQL

\set DISABLE_OPTIMIZATIONS off
\ir include/append.sql