[MDEV-4642] Index ignored on a query based on Aria table, while works fine with MyISAM Created: 2013-06-12 Updated: 2022-02-21 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - Aria |
| Affects Version/s: | 10.0.3, 5.5.31, 5.5 |
| Fix Version/s: | 5.5 |
| Type: | Bug | Priority: | Minor |
| Reporter: | Risato Stefano | Assignee: | Michael Widenius |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | not-10.1, not-10.2, not-10.3, not-10.4 | ||
| Environment: |
Both Windows and Linux |
||
| Attachments: |
|
| Description |
|
In a query I have a table with 7 million records, joined with another table with 300.000 records. First table:
Second table:
In the following query
the index Main2 is ignored when I use Aria engine, work fine with MyISAM. The explain plan show less than 1000 rows to read with MyISAM, and the full 7 million rows with Aria. If you need I can upload on your ftp the dump file to recreate the test case (50MB bz2). Thank you. |
| Comments |
| Comment by Elena Stepanova [ 2013-06-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi, Could you please run SHOW INDEX IN `data` and SHOW INDEX IN `aggrs` both when your index is used (with MyISAM), and when it's ignored (with Aria), and paste the results? Did you try to run ANALYZE TABLE? Thanks. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Risato Stefano [ 2013-06-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, I already ran ANALYZE TABLE; Here the results of the show index: mysql> show index in data_myisam;
------------
------------ mysql> show index in data_aria;
----------
---------- mysql> analyze table data_aria;
---------------
--------------- | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2013-06-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Is this with the very same data, that you are able to upload? If so then yes, please do upload it. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Risato Stefano [ 2013-06-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Uploaded as MDEV-4642_test.sql.bz2 in private folder. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2013-06-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi, I loaded your data and I'm getting identical plans with the MyISAM table and Aria table: MariaDB [test]> EXPLAIN EXTENDED SELECT STRAIGHT_JOIN SUM(FSTD) FROM aggrs ag USE INDEX (Ragr2) JOIN data_aria pr USE INDEX (Main2) ON (ag.Unita = pr.Unita) AND (ag.TipoU = pr.TipoU) AND (ag.Fase = pr.Fase) WHERE ag.Ragr2='DD4M';
-----
----- MariaDB [test]> EXPLAIN EXTENDED SELECT STRAIGHT_JOIN SUM(FSTD) FROM aggrs ag USE INDEX (Ragr2) JOIN data_myisam pr USE INDEX (Main2) ON (ag.Unita = pr.Unita) AND (ag.TipoU = pr.TipoU) AND (ag.Fase = pr.Fase) WHERE ag.Ragr2='DD4M';
-----
----- I'm using the top of maria/5.5 tree, but I'll try the release binaries as well. Could you please send your cnf file as well? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Risato Stefano [ 2013-06-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hello, here attached the my.ini used in 5.5.31 Windows 32 bit (production) and my.cnf used in 10.0.0.3 Linux 64 bit (test). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2013-06-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you, the config file helped. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2013-06-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
So, the problem appears due to aria_repair_threads > 1. To reproduce, use the SQL file from FTP. It takes quite a while to load it. I tried to reduce the data, but there is only that much one can do, ~ 4 mln rows are required for the problem to show up. However, the table data_myisam is not needed for the test, so it can be skipped (removed from the dump before loading). Basically, the first 480 lines of the dump is enough. I use ALTER to make the problem obvious because it's faster than reloading the data.
Output from the test described above: MariaDB [test]> show index in data_aria;
----------
---------- MariaDB [test]> EXPLAIN EXTENDED SELECT STRAIGHT_JOIN SUM(FSTD) FROM aggrs ag USE INDEX (Ragr2) JOIN data_aria pr USE INDEX (Main2) ON (ag.Unita = pr.Unita) AND (ag.TipoU = pr.TipoU) AND (ag.Fase = pr.Fase) WHERE ag.Ragr2='DD4M';
-----
----- MariaDB [test]> set aria_repair_threads=3; MariaDB [test]> alter table data_aria engine=aria; MariaDB [test]> show index in data_aria;
----------
---------- MariaDB [test]> EXPLAIN EXTENDED SELECT STRAIGHT_JOIN SUM(FSTD) FROM aggrs ag USE INDEX (Ragr2) JOIN data_aria pr USE INDEX (Main2) ON (ag.Unita = pr.Unita) AND (ag.TipoU = pr.TipoU) AND (ag.Fase = pr.Fase) WHERE ag.Ragr2='DD4M';
-----
----- MariaDB [test]> set aria_repair_threads=1; MariaDB [test]> alter table data_aria engine=aria; MariaDB [test]> show index in data_aria;
----------
---------- MariaDB [test]> EXPLAIN EXTENDED SELECT STRAIGHT_JOIN SUM(FSTD) FROM aggrs ag USE INDEX (Ragr2) JOIN data_aria pr USE INDEX (Main2) ON (ag.Unita = pr.Unita) AND (ag.TipoU = pr.TipoU) AND (ag.Fase = pr.Fase) WHERE ag.Ragr2='DD4M';
-----
----- I suppose the problem exists in previous versions as well, but it's probably not worth fixing it there, so I didn't try to reproduce. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Risato Stefano [ 2013-06-14 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thank you, the workaround is ok. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2019-05-02 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Still reproducible on current 5.5 (71a748d5), couldn't reproduce on 10.x. |