Bug #112634 Slow performance Mysql 8.x
Submitted: 5 Oct 2023 12:03 Modified: 5 Oct 2023 12:34
Reporter: Ammar Hadj Amor Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S5 (Performance)
Version:8.0 & 8.1 OS:Windows
Assigned to: CPU Architecture:x86

[5 Oct 2023 12:03] Ammar Hadj Amor
Description:
Hi,
I am using MySQL 5.7 with big tables and the performance seems to be quite good when selecting all records using and orber by clause.
I recently installed 8.0.34 and 8.1 and both showed performance issue using the same query and the same index.
It seems that the "select * from table order by field1" query using an order by clause without any where clause seems to not use the index or could be any other issue only in version 8.
The explain query command showed that it is using filesort and not keys. 

How to repeat:
Below are the step to reproduce the bug
1- create the table :

CREATE TABLE IF NOT EXISTS `table_33` (
  `_id` int(11) NOT NULL,
  `name` varchar(1024) DEFAULT NULL,
  `read_group` bigint(20) DEFAULT '1',
  `write_group` bigint(20) DEFAULT '1',
  `delete_group` bigint(20) DEFAULT '1',
  `changeheader_group` bigint(20) DEFAULT '1',
  `creation_date` bigint(20) DEFAULT NULL,
  `owner_` tinytext,
  `usermod` tinytext,
  `last_change_date` bigint(20) DEFAULT NULL,
  `details` longtext,
  `locked` int(11) NOT NULL DEFAULT '0',
  `isonline` int(11) NOT NULL DEFAULT '0',
  `v214` int(11) DEFAULT NULL,
  `d215` double DEFAULT NULL,
  `v216` int(11) DEFAULT NULL,
  `e217` longtext,
  `e218` longtext,
  `v219` int(11) DEFAULT NULL,
  `e220` longtext,
  `u221` longtext,
  `l222` longtext,
  `n223` longblob,
  `e224` longtext,
  `v225` int(11) DEFAULT NULL,
  `e226` longtext,
  `d227` double DEFAULT NULL,
  `v228` int(11) DEFAULT NULL,
  `e229` longtext,
  `e230` longtext,
  `d231` double DEFAULT NULL,
  `e232` longtext,
  `e233` longtext,
  `d234` double DEFAULT NULL,
  `v235` int(11) DEFAULT NULL,
  `e236` longtext,
  `e237` longtext,
  `i238` bigint(20) DEFAULT NULL,
  `i239` bigint(20) DEFAULT NULL,
  `d240` double DEFAULT NULL,
  `d241` double DEFAULT NULL,
  `e242` longtext,
  `e243` longtext,
  `d245` double DEFAULT NULL,
  `d244` double DEFAULT NULL,
  `e246` longtext,
  `k247` bigint(20) DEFAULT NULL,
  `v248` int(11) DEFAULT NULL,
  `e249` longtext,
  `s250` longtext,
  `c251` longtext,
  `u252` longtext,
  PRIMARY KEY (`_id`),
  KEY `_id_read_group_idx` (`_id`,`read_group`) USING BTREE,
  KEY `name_idx` (`name`(16)) USING BTREE,
  KEY `last_change_date_idx` (`last_change_date`) USING BTREE,
  KEY `owner__idx` (`owner_`(8)) USING BTREE
) ENGINE=MyISAM DEFAULT CHARSET=utf8;

2- Fill the table with data up to hundred of thousands rows or use the attached file to create and insert data

3- Run the following query against MySQL 5.7 and MySQL 8.0

 SELECT *  FROM  table_33 ORDER BY NAME  ASC LIMIT 50;

4- below are the response time for both version :

- MySQL 5.7 :
/* Affected rows: 0  Found rows: 50  Warnings: 0  Duration for 1 query: 0.328 sec. */
-MySQL 8.0 :
/* Affected rows: 0  Found rows: 50  Warnings: 0  Duration for 1 query: 3.032 sec. */

We can notice that version 8.0 is very slow compared to the version 5.7.
It is getting slower if the table contains more rows and columns.
I hope you can reproduce the bug.
Thanks for your help.
[5 Oct 2023 12:04] Ammar Hadj Amor
Zipped sql file containing table structure and data (210 000 rows)

Attachment: mysql_sample.zip (application/x-zip-compressed, text), 31.81 MiB.

[5 Oct 2023 12:34] MySQL Verification Team
Hello Ammar Hadj Amor,

Thank you for the report and test case.
IMHO this is duplicate of your existing bug report Bug #112597 which already describes this very problem. Request you to follow up in the existing bug report. Thank you.

regards,
Umesh