On disable_cost
Zhenghua Lyu <zlv@pivotal.io>
From: Zhenghua Lyu <zlv@pivotal.io>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2019-11-01T06:42:25Z
Lists: pgsql-hackers
Hi,
Postgres has a global variable `disable_cost`. It is set the value
1.0e10.
This value will be added to the cost of path if related GUC is set off.
For example,
if enable_nestloop is set off, when planner trys to add nestloop join
path, it continues
to add such path but with a huge cost `disable_cost`.
But 1.0e10 may not be large enough. I encounter this issue in
Greenplum(based on postgres).
Heikki tolds me that someone also encountered the same issue on Postgres.
So I send it here to
have a discussion.
My issue: I did some spikes and tests on TPCDS 1TB Bytes data. For
query 104, it generates
nestloop join even with enable_nestloop set off. And the final plan's
total cost is very huge (about 1e24). But If I enlarge the disable_cost to
1e30, then, planner will generate hash join.
So I guess that disable_cost is not large enough for huge amount of
data.
It is tricky to set disable_cost a huge number. Can we come up with
better solution?
The following thoughts are from Heikki:
> Aside from not having a large enough disable cost, there's also the
> fact that the high cost might affect the rest of the plan, if we have to
> use a plan type that's disabled. For example, if a table doesn't have any
> indexes, but enable_seqscan is off, we might put the unavoidable Seq Scan
> on different side of a join than we we would with enable_seqscan=on,
> because of the high cost estimate.
> I think a more robust way to disable forbidden plan types would be to
> handle the disabling in add_path(). Instead of having a high disable cost
> on the Path itself, the comparison add_path() would always consider
> disabled paths as more expensive than others, regardless of the cost.
Any thoughts or ideas on the problem? Thanks!
Best Regards,
Zhenghua Lyu
Commits
-
Doc: add detail about EXPLAIN's "Disabled" property
- 84b8fccbe5c2 18.0 landed
-
Adjust EXPLAIN's output for disabled nodes
- 161320b4b960 18.0 landed
-
Fix order of parameters in a cost_sort call
- 87b6c3c0b703 18.0 landed
-
Show number of disabled nodes in EXPLAIN ANALYZE output.
- c01743aa4866 18.0 landed
-
Treat number of disabled nodes in a path as a separate cost metric.
- e22253467942 18.0 landed
-
Remove grotty use of disable_cost for TID scan plans.
- e4326fbc60c4 18.0 landed