babak faghihian
babak faghihian

Reputation: 1189

delete query is runing and not delete any data

I use a query to delete about 9,000,000 rows but no rows deleted what is the problem?

 DELETE FROM `messages` WHERE  last_change < 1332201600 && last_change !=0

//1332201600 is time stamp

Upvotes: 0

Views: 77

Answers (2)

Marek Kwiendacz
Marek Kwiendacz

Reputation: 9814

Maybe problem is in and operator, and it should be:

DELETE FROM `messages` WHERE  last_change < 1332201600 AND last_change !=0

Upvotes: 2

Mark Byers
Mark Byers

Reputation: 838056

Deleting 9 million rows from a large table may take a long time. No rows will be deleted until the entire command completes and the transaction is committed. You have to be patient.

I would also check that your WHERE clause actually matches some rows. Try running this statement:

SELECT *
FROM `messages`
WHERE last_change < 1332201600 && last_change !=0
LIMIT 10

If this returns 10 rows (and it should if the information in your question is correct) then your original DELETE statement will delete at least those 10 rows.

Upvotes: 2

Related Questions