Re: why partition pruning doesn't work?
Pavel Stehule <pavel.stehule@gmail.com>
From: Pavel Stehule <pavel.stehule@gmail.com>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>,
Dmitry Dolgov <9erthalion6@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Jeff Janes <jeff.janes@gmail.com>, Ashutosh Bapat <ashutosh.bapat@enterprisedb.com>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2018-06-05T15:29:55Z
Lists: pgsql-hackers
2018-06-05 17:07 GMT+02:00 David Rowley <david.rowley@2ndquadrant.com>: > On 5 June 2018 at 22:31, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> > wrote: > > Maybe, David (added to cc) has something to say about all this, > especially > > whether he considers this a feature and not a bug fix. > > Thanks, Amit. I had missed this thread. > > Yeah. I admit if I'd thought about this case when I wrote the code, > then I'd have made any non-volatile Expr work, but I didn't :-( > > It was pointed out to be a few months ago in a comment in [1]. I > initially thought that this was v12 material, but it seems there are a > few people here that are pretty unhappy about it. > > I was going to describe what such a patch should look like here, but > that seemed like about as much work as writing it, so: > > Please see the attached patch. I've only just finished with it and > it's not fully done yet as there's still an XXX comment where I've not > quite thought about Exprs with Vars from higher levels. These might > always be converted to Params, so the code might be okay as is, but > I've not checked this yet, hence the comment remains. > > I'm slightly leaning towards this being included in v11. Without this > people are forced into hacks like WHERE partkey = (SELECT > stablefunc()); to get pruning working at all. If that SQL remains > after this patch then pruning can only take place during actual > execution. With the attached patch the pruning can take place during > the initialization of the executor, which in cases with many > partitions can be significantly faster, providing actual execution is > short. I'd rather people didn't get into bad habits like that if we > can avoid it. > This is really great Regards Pavel > [1] https://blog.2ndquadrant.com/partition-elimination-postgresql-11/ > > -- > David Rowley http://www.2ndQuadrant.com/ > PostgreSQL Development, 24x7 Support, Training & Services >
Commits
-
Fix up run-time partition pruning's use of relcache's partition data.
- e23bae82cf3d 11.0 landed
-
Fix access to just-closed relcache entry.
- bdc643e5e46f 11.0 landed
- b10edaf4bb44 10.5 landed
-
Improve ExecFindInitialMatchingSubPlans's subplan renumbering logic.
- 69025c5a07a1 11.0 landed
-
Improve commentary about run-time partition pruning data structures.
- 4e2323640333 11.0 landed
-
Fix run-time partition pruning code to handle NULL values properly.
- be3d90026a3c 11.0 landed
-
Assorted cosmetic cleanup of run-time-partition-pruning code.
- 321f648a312b 11.0 landed
-
Relocate partition pruning structs to a saner place.
- 939449de0e57 11.0 landed
-
Improve run-time partition pruning to handle any stable expression.
- 73b7f48f78d2 11.0 landed
-
Support partition pruning at execution time
- 499be013de65 11.0 cited