Bug #18468 Cluster is not optimizing on indexes provided. "Impossible WHERE noticed"

Submitted: 23 Mar 2006 19:05 Modified: 23 Mar 2006 19:32
Reporter: Jonathan Miller Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.1.8 OS:Linux (Linux 32 Bit OS)
Assigned to: Assigned Account CPU Architecture:Any

[23 Mar 2006 19:05] Jonathan Miller
Description:
A customer posted on the Cluster List that he was having issues getting NDB to use the indexes he provided, but InnoDB would use them without issues. I have recreated his issues and will attach test case and data files to this bug report. In addition I tried the test with ndb_use_exact_count=off and still did not get index seen in the explain.

+ CREATE TABLE `t1` (
+ `id` int(11) NOT NULL auto_increment,
+ `target_id` int(11) NOT NULL default '0',
+ `end_user_operation_id` int(11) NOT NULL default '0',
+ `user_id` int(11) NOT NULL default '0',
+ `carrier_id` int(11) NOT NULL default '0',
+ `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
+ `target_type_id` int(11) NOT NULL default '0',
+ `status` int(2) NOT NULL default '0',
+ `interface_type` int(2) NOT NULL default '0',
+ `interface_code` int(11) default NULL,
+ `la_id` int(11) default NULL,
+ `parent_id` int(11) default NULL,
+ PRIMARY KEY  (`id`),
+ KEY `eua_carrier_id_target_id_timestamp`
+ (`timestamp`,`carrier_id`,`target_id`),
+ KEY `eua_user_id_timestamp` (`user_id`,`timestamp`),
+ KEY `eua_timestamp` (`timestamp`)
+ ) ENGINE=ndbcluster DEFAULT CHARSET=latin1;
+ CREATE TABLE `t2` (
+ `id` int(11) NOT NULL auto_increment,
+ `target_id` int(11) NOT NULL default '0',
+ `end_user_operation_id` int(11) NOT NULL default '0',
+ `user_id` int(11) NOT NULL default '0',
+ `carrier_id` int(11) NOT NULL default '0',
+ `timestamp` datetime NOT NULL default '0000-00-00 00:00:00',
+ `target_type_id` int(11) NOT NULL default '0',
+ `status` int(2) NOT NULL default '0',
+ `interface_type` int(2) NOT NULL default '0',
+ `interface_code` int(11) default NULL,
+ `la_id` int(11) default NULL,
+ `parent_id` int(11) default NULL,
+ PRIMARY KEY  (`id`),
+ KEY `eua_carrier_id_target_id_timestamp`
+ (`timestamp`,`carrier_id`,`target_id`),
+ KEY `eua_user_id_timestamp` (`user_id`,`timestamp`),
+ KEY `eua_timestamp` (`timestamp`)
+ ) ENGINE=innodb DEFAULT CHARSET=latin1;

+ explain select id from t1 where timestamp >='2005-12-18 02:00:00' and timestamp <'2006-01-01 00:00:00';
+ id    select_type     table   type    possible_keys   key     key_len ref     rows    Extra
+ 1     SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
+ explain select id from t1 FORCE INDEX (eua_timestamp) where timestamp >='2005-12-18 02:00:00' and timestamp <'2006-01-01 00:00:00';
+ id    select_type     table   type    possible_keys   key     key_len ref     rows    Extra
+ 1     SIMPLE  NULL    NULL    NULL    NULL    NULL    NULL    NULL    Impossible WHERE noticed after reading const tables
+ explain select id from t2 where timestamp >='2005-12-18 02:00:00' and timestamp <'2006-01-01 00:00:00';
+ id    select_type     table   type    possible_keys   key     key_len ref     rows    Extra
+ 1     SIMPLE  t2      range   eua_carrier_id_target_id_timestamp,eua_timestamp        eua_timestamp    8       NULL    10      Using where; Using index
+ explain select id from t2 FORCE INDEX (eua_timestamp) where timestamp >='2005-12-18 02:00:00' and timestamp <'2006-01-01 00:00:00';
+ id    select_type     table   type    possible_keys   key     key_len ref     rows    Extra
+ 1     SIMPLE  t2      range   eua_timestamp   eua_timestamp   8       NULL    10      Using where; Using index

How to repeat:
See attachments
[23 Mar 2006 19:06] Jonathan Miller
Test case

Attachment: ndb_1.test (application/octet-stream, text), 2.29 KiB.

[23 Mar 2006 19:07] Jonathan Miller
Data for table t1

Attachment: index.dat (application/octet-stream, text), 29.71 KiB.

[23 Mar 2006 19:07] Jonathan Miller
Data for table t2

Attachment: index2.dat (application/octet-stream, text), 29.71 KiB.

[23 Mar 2006 19:09] Jonathan Miller
Contains original customer info

Attachment: index.txt (text/plain), 36.86 KiB.

[23 Mar 2006 19:32] Jonathan Miller
http://bugs.mysql.com/bug.php?id=18138

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.040 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.