Bug #13960 Problem with multiple indexes on row in ndbcluster
Submitted: 12 Oct 2005 12:43 Modified: 26 Oct 2005 23:33
Reporter: Justin Lambert Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:5.0.13 OS:Linux (Gentoo/Linux)
Assigned to: CPU Architecture:Any

[12 Oct 2005 12:43] Justin Lambert
Description:
I have run into a weird problem in our test migrating from mysql 4.1 myisam tables to mysql 5 ndb tables. I have one table that has in index on a column as well as the column being part of another index (active). 

mysql> show create table membership\G 
*************************** 1. row *************************** 
Table: membership 
Create Table: CREATE TABLE `membership` ( 
`organization_id` int(10) unsigned NOT NULL default '0', 
`user_id` int(10) unsigned NOT NULL default '0', 
`title` varchar(255) NOT NULL default '', 
`department` varchar(255) NOT NULL default '', 
`phone_extension` varchar(255) NOT NULL default '', 
`phone_extension_exclude` char(1) NOT NULL default '', 
`email_address` varchar(255) NOT NULL default '', 
`email_address_exclude` char(1) NOT NULL default '', 
`member_username` varchar(255) NOT NULL default '', 
`member_password` varchar(255) NOT NULL default '', 
`org_phone` varchar(255) NOT NULL default '', 
`org_phone_exclude` char(1) NOT NULL default '', 
`org_fax` varchar(255) NOT NULL default '', 
`org_fax_exclude` char(1) NOT NULL default '', 
`org_cell` varchar(255) NOT NULL default '', 
`org_cell_exclude` char(1) NOT NULL default '', 
`org_pager` varchar(255) NOT NULL default '', 
`role` varchar(255) NOT NULL default '', 
`assistant` int(10) unsigned NOT NULL default '0', 
`active` char(1) NOT NULL default 'Y', 
`remote_key_mem` varchar(255) NOT NULL default '', 
PRIMARY KEY (`organization_id`,`user_id`), 
KEY `user_id` (`user_id`), 
KEY `email_address` (`email_address`), 
KEY `organization_id` (`organization_id`,`active`), 
KEY `active` (`active`) 
) ENGINE=ndbcluster DEFAULT CHARSET=latin1 

This query should be returning results: 
mysql> select organization_id, user_id, active from membership where organization_id = 23 and active = 'Y' limit 1\G 
Empty set (0.05 sec) 

As seen by this query (using like with at % at the begining to force it not to use an index) 
mysql> select organization_id, user_id, active from membership where organization_id = 23 and active like '%Y%' limit 1\G 
*************************** 1. row *************************** 
organization_id: 23 
user_id: 134 
active: Y 
1 row in set (0.04 sec) 

I also made sure there were no extra spacing around active even though it is a CHAR(1) with: 
mysql> select length(active) from membership where user_id=134; 
+----------------+ 
| length(active) | 
+----------------+ 
| 1 | 
+----------------+ 
1 row in set (0.05 sec) 

If I drop either the active index or (`organization_id`,`active`) index, queries work exactly as expected. I upgraded to 5.0.13 a bit earlier today and am still seeing the same problem. 

How to repeat:
See above.
[24 Oct 2005 19:04] Hartmut Holzgraefe
can you please add EXPLAIN output for both queries,
or even better provide us with a dump of the membership
table so that we can test things out for ourselves?
[26 Oct 2005 17:22] Justin Lambert
Upgrading to 5.0.15 fixed this issue.  If you would still like the dataset I can provide that for you, otherwise I think this bug can be closed.