[MDEV-18089] optimizer is wrong Created: 2018-12-27 Updated: 2022-05-12 Resolved: 2021-09-30 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Optimizer |
| Affects Version/s: | 10.3.11 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Philip orleans | Assignee: | Unassigned |
| Resolution: | Not a Bug | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux |
||
| Issue Links: |
|
||||||||
| Description |
|
I checked this with MS SQL and it behaves correctly. |
| Comments |
| Comment by Elena Stepanova [ 2018-12-29 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
I think it's the same implicit charset conversion issues already discussed in another bug report | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2018-12-29 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
There is a further problem, using RocksDB. Take this query on a very large table. Please note that all fields are boolean, i.e. numeric, and the three fields are indexed.
I had to stop the query after 12 hours. It is basically useless for BIG data. This query in MsSQL may take 15 minutes max. I could try InnoDB but it will require several times the disk space as RocksDB. Should I try TokuDB, or this is an issue with the optimizer? I want to emphasize that anybody can do a faster job on the same query using a CSV file and plain old AWK. It is trivial. The entire data fits in memory:
| |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2019-01-22 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Take a table with a single field varchar(10) primary key | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-03-25 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
consider this:
as you can see, one cannot just convert bigint to a varchar once. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2020-03-25 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
I disagree, you take the bigint and convert it to varchar representation, that is '9' in the case, and retrieve any record that matches, '9'. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-03-26 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
This is a different issue. My example shows that if comparison rules are as documented here: https://mariadb.com/kb/en/type-conversion/#rules-for-conversion-on-comparison then the example above cannot use an index or convert bigint to varchar once. You're saying that the comparison rules should be different. Perhaps, but they're very difficult to change, MariaDB always worked like this, since 2010, and MySQL always worked like that since 1998. It's a lot of history to break. Besides, SQL Standard says that one cannot compare a number to a string anyway, so any conforming database implementation should just throw an error if you'd try to do that. | |||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2020-03-26 ] | |||||||||||||||||||||||||||||||||||||||||||||
|
Then close the issue. |