Doctorbal / zabbix-postgres-partitioning

Zabbix PostgreSQL version 11 Native Partitioning
MIT License
43 stars 15 forks source link

constraint_exclusion #1

Closed adrianlzt closed 5 years ago

adrianlzt commented 5 years ago

I see that you recommend setting constraint_exclusion = on.

From the postgres doc:

Currently, constraint exclusion is enabled by default only for cases that are often used to implement table partitioning. Turning it on for all tables imposes extra planning overhead that is quite noticeable on simple queries, and most often will yield no benefit for simple queries. If you have no partitioned tables you might prefer to turn it off entirely.

By default it takes value partition.

So what's the point of turning on completely?

Thanks for the guide!

adrianlzt commented 5 years ago

After reading more postgres docs, looks like the parameter that should be turned on is enable_partition_pruning (by default is on).

constraint_exclusion is for partition tables with inheritance

Doctorbal commented 5 years ago

@adrianlzt thanks for bringing this up as I missed this point!

constraint_exclusion allows the query planner to avoid including partitions in a query when it can prove they can't provide useful rows to satisfy it.

When I originally wrote the docs it was geared around PostgreSQL version 10 and the official docs suggested to have constraint_exclusion enabled for declarative partitioning.

Since the release of PostgreSQL 11, the official version 11 docs do suggest to use the enable_partition_pruning for declarative partitioning.

The good news is both are enabled by default; but it should be known to the user to make sure they are enabled.

I'll update the notes to address the difference.

Doctorbal commented 5 years ago

@adrianlzt, I updated the notes to address your input. Please let me know if you have any more questions.

adrianlzt commented 5 years ago

All good. Thanks!