Re: [HACKERS] Runtime Partition Pruning
David Rowley <david.rowley@2ndquadrant.com>
From: David Rowley <david.rowley@2ndquadrant.com>
To: Beena Emerson <memissemerson@gmail.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>,
Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>, Robert Haas <robertmhaas@gmail.com>, amul sul <sulamul@gmail.com>, "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>,
Dilip Kumar <dilipbalaut@gmail.com>
Date: 2018-01-10T01:51:51Z
Lists: pgsql-hackers
Attachments
- runtime_prune_drowley_v8.patch (application/octet-stream) patch v8
On Tue, Jan 9, 2018 at 2:24 PM, Beena Emerson <memissemerson@gmail.com> wrote: > prepare abc_q1 (int, int, char) as select * from ab_c where a BETWEEN > $1 and $2 AND b <= $3; > > --after 5 runs: abc_a2_b3 is not pruned. This seems to be down to an existing bug. I'm not yet sure if it's caused by faster_partition_prune_v17, or if it exists in master. Basically RelOptInfo->partition_rels can contain duplicates for relations. In your example while debugging make_partition_pruneinfo I see: list_nth_int(best_path->partitioned_rels,0) 1 list_nth_int(best_path->partitioned_rels,1) 3 list_nth_int(best_path->partitioned_rels,2) 8 list_nth_int(best_path->partitioned_rels,3) 13 list_nth_int(best_path->partitioned_rels,4) 3 list_nth_int(best_path->partitioned_rels,5) 8 list_nth_int(best_path->partitioned_rels,6) 13 There should only be 4 items in this list, not 7. make_partition_pruneinfo might have been a bit naive to assume this couldn't happen, so I've coded it to be a bit more resilient to this happening. It'll still end up creating another sub-PartitionPruneInfo and slotting into the same place, but it'll no longer attempt to translate the prunequals twice... which was what was causing the problem. I'd been a bit sloppy and assigned the output of adjust_appendrel_attrs() back to the prunequals which is a parameter to the function instead of assigning to a local variable like I've done now. On 9 January 2018 at 22:22, Beena Emerson <memissemerson@gmail.com> wrote: >> postgres=# explain (analyze, costs off, summary off, timing off) >> execute abc_q1 (1, 2); >> ERROR: partition missing from Append subplans This also seems to be fixed by the above fix. > =# explain (analyze, costs off, summary off, timing off) execute abc_q1 (1, 1); > ERROR: operator 1057 is not a member of opfamily 1976 This seems to be broken in faster_partition_prune_v17 where in classify_partition_bounding_keys() the code properly checks if the clause matches the partition key for OpExpr, but fails to do the same for ScalarArrayOpExpr. I'll report to Amit on the thread for that patch. I'll also investigate the duplication in RelOptInfo->partition_rels and report that in another thread. Can you confirm that case 1 and 2 are working with the attached? -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Initialize ExprStates once in run-time partition pruning
- 1957f8dabf8d 11.0 landed
-
Add bms_prev_member function
- 5c0675215e15 11.0 landed
-
Support partition pruning at execution time
- 499be013de65 11.0 landed
-
Document partprune.c a little better
- 971d7ddbe19a 11.0 landed
-
Fix crash in pg_replication_slot_advance
- 6f1d723b6359 11.0 cited
-
Add parallel-aware hash joins.
- 1804284042e6 11.0 cited
-
Fix typo.
- 487a0c1518af 11.0 cited
-
Allow --with-bonjour to work with non-macOS implementations of Bonjour.
- 9b9cb3c4534d 11.0 cited
-
Mention need for --no-inc-recursive in rsync command
- 2c74e6c1dcc5 11.0 cited