[MDEV-26659] optimizer fails to consider character set conversion cost on PK joins Created: 2021-09-21 Updated: 2021-12-21 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Character Sets, Optimizer |
| Affects Version/s: | 10.6.4 |
| Fix Version/s: | 10.6 |
| Type: | Bug | Priority: | Major |
| Reporter: | Philip orleans | Assignee: | Sergei Petrunia |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux |
||
| Attachments: |
|
| Description |
|
I isolated an amazing, catastrophic lack of performance for a common business operation. Something that with the same tables and data takes 0.5 seconds in MS SQL, in Mariadb it takes 15 minutes, and is not related to the engine, for I tried with innodb, memory and rocksdb with identical results.
if you try to do the result is the same This operation takes 1/2 in Ms SQL. |
| Comments |
| Comment by Philip orleans [ 2021-09-21 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I just tested with Mysql 8.26, same data and columns
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I'm having trouble reproducing this:
How can callid be NULL if the column is declared NOT NULL? What does ANALYZE FORMAT=JSON thequery show for yoU? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I am uploading a dump of the two tables with data. It creates a database called test.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Silly me on the is null comment, its obviously a join. Me gets another cofffee. Confirmed, thanks for the test case philip_38 Comes down to callid in both tables have a different character set:
A perf profile looks like:
So the problem is that the character set of each isn't the same and its converting each row. Making the the same character set causes the problem to go away.
Also in 10.7 there is currently a preview of a UUID data type - https://mariadb.org/10-7-preview-feature-uuid-data-type/ that I've prototyped below:
For the moment I recommend one of:
From the warnings we see MySQL-8.0 deliberately avoid the query plan because of the character set differences. Hence leaving the bug open for now.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Question: this problem when different tables are made of different character sets si terrible, Is there a way to enforce a single character set server-wide? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The configuration files is using
this makes no sense. The question is: when MariaDB is installing, why is choosing this particular character set and not latin1? I live in the USA and only speak Romance languages. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Philip orleans [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
There is a further problem:
so how do I keep latin1 always, regardless of the OS preference or default? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2021-09-22 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
> Is there a way to enforce a single character set server-wide? The server has a default character set, that databases inherit by default, that tables inherit by default, that columns inherit by default. There is no single enforcement. The database does what is instructed. > As you say, Mysql (Oracle) could care less, it performed perfectly in this case. If they can do it, why MariaDB cannot look at the code and apply the same idea? That is why I re-titled the issue. So that it could get the attention to the cause of the problem. An off topic discussion on packaging defaults, or a feature request that enforces character set, will only distract this issue from fixing the optimizer choices. I'll take no further part in this issue. |