[MDEV-5721] Using too big key for internal temp tables MariaDB 5.5.35 Created: 2014-02-24  Updated: 2014-10-11  Resolved: 2014-08-05

Status: Closed
Project: MariaDB Server
Component/s: Optimizer
Affects Version/s: 5.3.12, 5.5.35, 5.5.36, 10.0.8
Fix Version/s: 5.5.40, 10.0.14, 5.3.13

Type: Bug Priority: Major
Reporter: Meik Suchlich Assignee: Igor Babaev
Resolution: Fixed Votes: 0
Labels: None
Environment:

debian 7 wheezy mysql_multi environment


Attachments: File cq-broken.sql.gz     File cq-select.sql     File cq-tables.sql     File cq-working.sql.gz     File example-data.sql     File mdev5721.test     File my-ticket.cnf     File tables.sql    
Issue Links:
Relates
relates to MDEV-6838 Using too big key for internal temp t... Closed

 Description   

We got this error:

Using too big key for internal temp tables

it seems that the bug described in https://bugs.launchpad.net/maria/+bug/957409 is not fixed for all cases.

the testcase described there works.
But in our case the workaround (SET GLOBAL optimizer_switch = 'derived_with_keys=off';) is needed, so that our complex statement works.

The statement is a complex statement on innodb-tables with inner selects and substring_index-fkt and group by/order by having count. belonging to three tables.
Test case and statement delivered. Tables.sql contains select statement which causes the error.



 Comments   
Comment by Elena Stepanova [ 2014-02-24 ]

Hi,

A complete test case would be perfect, but meanwhile, could you please provide

  • the offending query;
  • EXPLAIN for the offending query;
  • the table structures for the involved tables (SHOW CREATE TABLE);
  • SHOW INDEX for the tables;
  • your config file(s)?

Thanks.

Comment by Meik Suchlich [ 2014-02-25 ]

i'll do an upload for config

Comment by Meik Suchlich [ 2014-02-25 ]

Example-Data for the test-tables to recreate the error.
The error also occures on MariaDB 5.5.34.

Comment by Meik Suchlich [ 2014-02-25 ]

Here are the comments as file: config and tables.
The serialized-column of fd contains serilized java-object.

Comment by Meik Suchlich [ 2014-02-25 ]

new testdata reduced on the only necessary information

Comment by Elena Stepanova [ 2014-02-27 ]

Thanks for the reproducible test case.

The reported test case is attached as mdev5721.test. It is the exact same data and query, just all together in one file in the proper order.

I have also reduced and somewhat modified it a little more, below is what's left. It might be a bit more convenient for initial debugging, but it's absolutely necessary to also check the initial test case after the fix, because it the one below uses MyISAM, while the initial one InnoDB, and there might be some other important differences.

CREATE TABLE `td` (
  `id` varchar(255) NOT NULL DEFAULT '',
  `familyid` int(11) DEFAULT NULL,
  `withdrawndate` date DEFAULT NULL,
  KEY `index_td_familyid_id` (`familyid`,`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
CREATE TABLE `fd` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `activefromts` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
  `shortdescription` text,
  `useraccessfamily` varchar(512) DEFAULT NULL,
  `serialized` longtext,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
insert into fd values (38,'2013-03-04 07:49:22','desc','CODE','string');
insert into td values ('picture/89/1369722032695.pmd',89,NULL);
insert into td values ('picture/90/1369832057370.pmd',90,NULL);
 
SELECT * FROM fd x,
(
SELECT
  fd.useraccessfamily,
  fd.serialized AS picturesubuser,
  COUNT(*)
FROM
  fd, td
GROUP BY fd.useraccessfamily, picturesubuser
) y
WHERE
  x.useraccessfamily = y.useraccessfamily 
;

Comment by Christian Quast [ 2014-06-06 ]

Hi...

I also encounter this problem and disabling derived keys works for me as well. My test case is similar to that of the OP as I am also using sub selects and 'group by' statements. Interestingly the size of the tables matters. Having a few more entries in tables 'b' (+1) and 'c' (+2) triggers the error. Table 'a' is not used in the select and I haven't tested if this table is strictly necessary to reproduce the error.

I also created a reproducible test case. Which I will attach to this bug report as well.

Comment by Christian Quast [ 2014-06-06 ]

ups... forgot to mention

the rows that reference the additional entry 'pa = AB098503' in table 'b' that is only present in the broken example is excluded by the 'rt is NULL' part when joining table 'b'.

Also, decreasing the width of the varchar fields a, i, t that are used in the group by statement to a combined width of less then 700 characters solves the problem without the need to disable derived keys.

Comment by Igor Babaev [ 2014-08-05 ]

The fix for this bug was pushed into the 5.3 tree (rev 3793).

Generated at Thu Feb 08 07:06:33 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.