[MDEV-5633] Better Support For Partitions/Prune By Date Created: 2014-02-08 Updated: 2023-11-03 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Partitioning |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | BELUGABEHR | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Description |
|
I created a table based on a hash of a date:
I would think that the query engine could prune searches since the hash value is, in my situation, monotonically increasing, but it does not appear to be the case. In a range search, the optimizer should be able to put the lower and upper bounds of the range into the hash function to come up with the upper and lower bounds for pruning partitions. |
| Comments |
| Comment by Sergei Golubchik [ 2014-02-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hashes don't work that way. They generally don't preserve the order, so even if the function would be monotonically increasing, the hash of it wouldn't be. That's why an optimizer cannot possibly guess the range of hash values from the range of hash arguments. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by BELUGABEHR [ 2014-02-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If I may: I read from the MySQL Manual:
Given that remark, can date operators be special-cased to allow for this behavior? Given: PARTITION BY HASH( DAYOFYEAR(hired)) and the MOD of the hash function, it can be determined which range of partitions contain given date.
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2014-02-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I see. Yes, to a certain extent it's possible. But it would need rather big changes in the optimizer, so we cannot implement it anytime soon. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by BELUGABEHR [ 2014-02-14 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
More formally stated:
The optimizer should be able to prune out all partitions except partitions: 1,2,3 |