mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-22 13:40:56 +08:00
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.
3 lines
54 B
SQL
3 lines
54 B
SQL
\set DISABLE_OPTIMIZATIONS off
|
|
\ir include/append.sql
|