Sagewire Logo

Simple MySQL Index

2 Message(s) by 2 Author(s) originally posted in mysql database


From: McMurphy Date:   Thursday, June 28, 2007
I have a single table which I'd like to search on a unique column
varchar(15) that may have some null s. Employee social club member no,
some employees have a number and others do not. Those that do have a number
will all have a unique number.

I had added an index using:
ALTER TABLE employees ADD INDEX(emp_socialclubno);

However when I run :
mysql> explain select employeeid from employees where
emp_socialclubno=103833988;
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_key s | key | key_len |
ref | row s | Extra |
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | properties | ALL | emp_socialclubno | NULL | NULL |
NULL | 170361 | Using where |
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)

So this indicates that even though the emp_socialclubno column has an index
it isn't being used when this column is searched ?

Is this right or am I missing something ?

Thanks in advance...


From: lark Date:   Thursday, July 05, 2007
wrote in message:
I have a single table which I'd like to search on a unique column
varchar(15) that may have some nulls. Employee social club member no,
some employees have a number and others do not. Those that do have a number
will all have a unique number.
I had added an index using:
ALTER TABLE employees ADD INDEX(emp_socialclubno);
However when I run:
mysql> explain select employeeid from employees where
emp_socialclubno=103833988;
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
| id | select_type | table | type | possible_keys | key | key_len |
ref | rows | Extra |
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
| 1 | SIMPLE | properties | ALL | emp_socialclubno | NULL | NULL |
NULL | 170361 | Using where |
+----+-------------+------------+------+---------------+------+---------+------+--------+-------------+
1 row in set (0.00 sec)
So this indicates that even though the emp_socialclubno column has an index
it isn't being used when this column is searched ?
Is this right or am I missing something ?
Thanks in advance...looks like your query is for table employees but the explain is run on


properties. these are two different tables!!!



Next Message: mysqldump select query


Blogs related to Simple MySQL Index

Re: Simple MySQL problem
Re: Simple MySQL problem.

MySQL-Simple-Query-Browser-0.1.10
I've write a simple script to manage MySQL database, you can see it at http://docs.google.com/Doc?id=dhr2c3jq_8g3vv2t below is from that link, but not valid for write rules #!/usr/bin/env python """ for my lovely parent ...

Re: simple mysql statement giving error.. can't figure it out.
Re: simple mysql statement giving error.. can't figure it out.

Very simple MySql question.. I think.
Very simple MySql question.. I think.

Multiple-column index not working
id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE messages ref recipientid recipientid 4 const,const 8352 It seems as though MySQL is not traversing the multiple column index to the status column. ...

Re: -MaxRecords
Jason Huck to Lasso Talk on 2007-07-05 07:35:50 - On 7/5/07, Simon Forster wrote: > Smells a little hack like (why doesn't -maxrecords do this > automagically if talking to MySQL? Ah. Probably because there's no > easy way to get total ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional