I have only one table in my my database which use InnoDB storage engine.
Size of table is 23 millions rows approx. with database size 25 GB.
Below listed update query taking very very long time ( > 30 min) even though it's using index.
UPDATE tableA SET acctstoptime = '2010-07-19 14:17:26', acctsessiontime = unix_timestamp('2010-07-19 14:17:26') - unix_timestamp(acctstarttime), acctterminatecause = '', acctstopdelay = 3078149 WHERE acctstoptime IS NULL AND nasipaddress = '1.1.1.1' AND acctstarttime <= '2010-07-19 14:17:26'
Here is explain plan:
mysql> explain
-> select count(*) from tableA where acctstoptime IS NULL AND nasipaddress = '1.1.1.1' AND acctstarttime <= '2010-07-19 14:17:26';
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
| 1 | SIMPLE | tableA | index_merge | acctstarttime,acctstoptime,nasipaddress | nasipaddress,acctstoptime | 17,9 | NULL | 78334 | Using intersect(nasipaddress,acctstoptime); Using where |
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
Any suggestion how do I make it faster?
Size of table is 23 millions rows approx. with database size 25 GB.
Below listed update query taking very very long time ( > 30 min) even though it's using index.
UPDATE tableA SET acctstoptime = '2010-07-19 14:17:26', acctsessiontime = unix_timestamp('2010-07-19 14:17:26') - unix_timestamp(acctstarttime), acctterminatecause = '', acctstopdelay = 3078149 WHERE acctstoptime IS NULL AND nasipaddress = '1.1.1.1' AND acctstarttime <= '2010-07-19 14:17:26'
Here is explain plan:
mysql> explain
-> select count(*) from tableA where acctstoptime IS NULL AND nasipaddress = '1.1.1.1' AND acctstarttime <= '2010-07-19 14:17:26';
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
| 1 | SIMPLE | tableA | index_merge | acctstarttime,acctstoptime,nasipaddress | nasipaddress,acctstoptime | 17,9 | NULL | 78334 | Using intersect(nasipaddress,acctstoptime); Using where |
+----+-------------+---------+-------------+-----------------------------------------+---------------------------+---------+------+-------+---------------------------------------------------------+
Any suggestion how do I make it faster?