w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Postgres ignores table constraints, scans all inherited tables even if constraints don't match

Ok, I found it. I was using current_date - a non-constant parameter, in the where clause. Changing current_date to a literal value, fixed it.

Constraint exclusion only works when the query's WHERE clause contains constants. A parameterized query will not be optimized, since the planner cannot know which partitions the parameter value might select at run time. For the same reason, "stable" functions such as CURRENT_DATE must be avoided.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.