Re: [HACKERS] path toward faster partition pruning
David Rowley <david.rowley@2ndquadrant.com>
Attachments
- v38_drowley_delta1.patch (application/octet-stream) patch v38
On 21 March 2018 at 00:07, Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> wrote: > Attached is further revised version. Hi Amit, Thanks for sending the v38 patch. I started reviewing this, but I just ended up starting to hack at the patch instead. It's still got quite a bit of work to be done as I think, unfortunately, the cross type stuff is still pretty broken. There's not really any sort of checking done to make sure you've found a valid cross type hash or compare function in the code which results in errors like: create table hashp (a int, b numeric) partition by hash(a,b); create table hashp1 partition of hashp for values with (modulus 4, remainder 0); create table hashp2 partition of hashp for values with (modulus 4, remainder 1); create table hashp3 partition of hashp for values with (modulus 4, remainder 2); create table hashp4 partition of hashp for values with (modulus 4, remainder 3); explain select * from hashp where a = 3::smallint and b = 1.0; ERROR: cache lookup failed for function 0 I'm not really sure if this should be a matter of doing an if (!OidIsValid(new_supfuncid)) return false; I think the context->partsupfunc must be pretty broken in cases like: create table listp (a bigint) partition by list(a); create table listp1 partition of listp for values in(1); select * from listp where a <> 1::smallint and a <> 1::bigint; The current patch simply just remembers the last comparison function for comparing int8 to int4 and uses that one for the int8 to int2 comparison too. Probably we need to cache the comparison function's Oid in with the Expr in the step and use the correct one each time. I'm unsure of how the fmgr info should be cached, but looks like it certainly cannot be cached in the context in an array per partition key. I've so far only thought some sort of hash table, but I'm sure there must be a much better way to do this. I started hacking it partition.c and ended up changing quite a few things. I changed get_partitions_for_keys into 3 separate functions, one for hash, list and range and tidied a few things up in that area. There were a few bugs, for example passing the wrong value for the size of the array into get_partitions_excluded_by_ne_datums. I also changed how the Bitmapsets are handled in the step functions and got rid of the Noop step type completely. I also got rid of the passing of the srcparts into these functions. I think Roberts idea is to process the steps in isolation and just combine the partitions matching each step. It would be great if we could coordinate our efforts here. I'm posting this patch now just in case you're working or about to work on this. In the meantime, I'll continue to drip feed cleanup patches. I'll try to start writing some comments too, once I figure a few things out... -- David Rowley http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Training & Services
Commits
-
Fix assorted partition pruning bugs
- d758d9702e2f 11.0 landed
-
Make gen_partprune_steps static
- d1e2cac5ff7e 11.0 landed
-
Remove useless 'default' clause
- c775fb9e18ac 11.0 landed
-
Reorganize partitioning code
- da6f3e45ddb6 11.0 landed
-
Use custom hash opclass for hash partition pruning
- fafec4cce814 11.0 landed
-
Blindly attempt to fix sepgsql tests broken due to 9fdb675fc5.
- 4f813c7203e0 11.0 landed
-
Attempt to fix endianess issues in new hash partition test.
- 40e42e1024c5 11.0 landed
-
Faster partition pruning
- 9fdb675fc5d2 11.0 landed
-
For partitionwise join, match on partcollation, not parttypcoll.
- 2af28e603319 11.0 landed
-
Revise API for partition bound search functions.
- f724022d0ae0 11.0 landed
-
Revise API for partition_rbound_cmp/partition_rbound_datum_cmp.
- b0229235564f 11.0 landed
-
Fix possible crash in partition-wise join.
- f069c91a5793 11.0 cited
-
Refactor code for partition bound searching
- 9aef173163ae 11.0 landed
-
New C function: bms_add_range
- 84940644de93 11.0 landed
-
Add extensive tests for partition pruning.
- 8d4e70a63bf8 11.0 landed
-
Add null test to partition constraint for default range partitions.
- 7b88d63a9122 11.0 cited
-
Remove BufFile's isTemp flag.
- 11e264517dff 11.0 cited
-
Make OWNER TO subcommand mention consistent
- bf54c0f05c0a 11.0 cited
-
Fix index matching for operators with mixed collatable/noncollatable inputs.
- cb37c291060d 9.2.0 cited