Re: New design for FK-based join selectivity estimation
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Tomas Vondra <tomas.vondra@2ndquadrant.com>
Cc: pgsql-hackers@postgresql.org
Date: 2016-06-15T23:00:08Z
Lists: pgsql-hackers
Attachments
- fk-estimates-reworked-2.patch (text/x-diff) patch
Tomas Vondra <tomas.vondra@2ndquadrant.com> writes: > Attached is a reworked patch, mostly following the new design proposal > from this thread. I've whacked this around quite a bit and am now reasonably happy with it. The issue of planning speed hit should be pretty much gone, although I've not done testing to prove that. I've rearranged the actual selectivity calculation some too, because tests I did here did not look very good for anything but the plain-inner-join case. It may be that more work is needed there, but at least there's reasonable commentary about what we're doing and why. I have not adopted the plan of ignoring single-column FKs. While it would only take a couple more lines to do so, I think the argument that there will be a material planning speed hit no longer has much force. And I see a couple of arguments in favor of allowing this code to trigger on single-column FKs. First, it should work well even when pg_statistic data is missing or out of date, which would be an improvement; and second, we are likely not going to get much beta testing of the behavior if we restrict it to multi-col FKs. So I think we should ship it like this for beta even if we end up adding a filter against single-column FKs for release. Comments and testing appreciated. regards, tom lane
Commits
-
Fix FK-based join selectivity estimation for semi/antijoins.
- f4f195d15c7c 9.6.2 landed
- 7fa93eec4e0c 10.0 landed
-
Restore foreign-key-aware estimation of join relation sizes.
- 100340e2dcd0 9.6.0 cited