mikeknox
Thu 26th Sep '02, 11:13am
I'm still trying to sort out why my inserts and updates are running slowly - and came across this when trying to ensure that my query used an index.
Logging to file 'duff.log'
mysql> desc tmp_dhcp;
+-------------+---------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------------------+----------------+
| startt | datetime | | | 0000-00-00 00:00:00 | |
| endt | datetime | | | 0000-00-00 00:00:00 | |
| ip | varchar(15) | | MUL | | |
| mac_address | varchar(17) | | MUL | | |
| openflag | tinyint(3) unsigned | YES | | NULL | |
| lastudate | datetime | | | 0000-00-00 00:00:00 | |
| rowid | bigint(15) | | PRI | NULL | auto_increment |
| updates | int(11) | YES | | 0 | |
| lastaction | varchar(8) | | | | |
+-------------+---------------------+------+-----+---------------------+----------------+
9 rows in set (0.00 sec)
mysql> show index from tmp_dhcp;
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Comment |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
| tmp_dhcp | 0 | PRIMARY | 1 | rowid | A | 0 | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 1 | ip | A | NULL | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 2 | mac_address | A | NULL | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 3 | startt | A | 0 | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 1 | mac_address | A | NULL | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 2 | ip | A | NULL | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 3 | startt | A | NULL | NULL | NULL | |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
7 rows in set (0.00 sec)
mysql> explain select * from tmp_dhcp use index (mac_address, ip, startt)
-> where mac_address='00:01:02:0f:e1:47'
-> and ip='14.193.44.4'
-> and startt<='01/09/2002 02:23:51'
-> and endt>='02/09/2002 02:23:50'
-> and openflag=1;
ERROR 1072: Key column 'mac_address' doesn't exist in table
mysql> quit
perror - just states unknown errors
Any ideas? Like I've got to be doing something really stupid - right?
Logging to file 'duff.log'
mysql> desc tmp_dhcp;
+-------------+---------------------+------+-----+---------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+---------------------+------+-----+---------------------+----------------+
| startt | datetime | | | 0000-00-00 00:00:00 | |
| endt | datetime | | | 0000-00-00 00:00:00 | |
| ip | varchar(15) | | MUL | | |
| mac_address | varchar(17) | | MUL | | |
| openflag | tinyint(3) unsigned | YES | | NULL | |
| lastudate | datetime | | | 0000-00-00 00:00:00 | |
| rowid | bigint(15) | | PRI | NULL | auto_increment |
| updates | int(11) | YES | | 0 | |
| lastaction | varchar(8) | | | | |
+-------------+---------------------+------+-----+---------------------+----------------+
9 rows in set (0.00 sec)
mysql> show index from tmp_dhcp;
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Comment |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
| tmp_dhcp | 0 | PRIMARY | 1 | rowid | A | 0 | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 1 | ip | A | NULL | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 2 | mac_address | A | NULL | NULL | NULL | |
| tmp_dhcp | 0 | dhcp_ix1 | 3 | startt | A | 0 | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 1 | mac_address | A | NULL | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 2 | ip | A | NULL | NULL | NULL | |
| tmp_dhcp | 1 | dhcp_ix2 | 3 | startt | A | NULL | NULL | NULL | |
+----------+------------+----------+--------------+-------------+-----------+-------------+----------+--------+---------+
7 rows in set (0.00 sec)
mysql> explain select * from tmp_dhcp use index (mac_address, ip, startt)
-> where mac_address='00:01:02:0f:e1:47'
-> and ip='14.193.44.4'
-> and startt<='01/09/2002 02:23:51'
-> and endt>='02/09/2002 02:23:50'
-> and openflag=1;
ERROR 1072: Key column 'mac_address' doesn't exist in table
mysql> quit
perror - just states unknown errors
Any ideas? Like I've got to be doing something really stupid - right?