there ways to speed this up?
I have a table with about 100 million rows:
I am trying to delete just a few of these rows (the following select
takes a couple of seconds):
SELECT count(*) -> FROM UserSnap
-> WHERE LogDate<now() - INTERVAL 750 DAY;
+----------+
| count(*) |
+----------+
| 308969 |
+----------+
DELETE FROM UserSnap WHERE LogDate<now() - INTERVAL 750 DAY;
That delete query takes hours to run. The structure of the table is:
desc UserSnap;
+----------+-------------+------+-----+---------------------+-------+
| Field | Type | Null | Key | Default | Extra |
+----------+-------------+------+-----+---------------------+-------+
| LogDate | datetime | | PRI | 0000-00-00 00:00:00 | |
| Period | tinyint(4) | | PRI | 0 | |
| UserName | varchar(50) | | PRI | | |
| RateType | varchar(50) | | PRI | default | |
| Rate | float | YES | | NULL | |
+----------+-------------+------+-----+---------------------+-------+
Any suggestions on why this is slow, and what to do about it?