Too many DELETE statements
| From: | news.php.net | Date: | Thu, 02 Dec 2004 03:02:49 +0000 |
| Subject: | Too many DELETE statements | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-203334@lists.php.net to get a copy of this message | ||
I have 160,000+ members in my site. 40,000 of them have not logged in since
2003 and they should be deleted. A member is not deleted from only one
table. Based on user id, he should be deleted from 5 tables and also his
photo, if any, should be unlink(ed).
I tried to do that 10 by 10 using:
$query = "delete from table1 where userid = " . $ID;
$result = mysql_query($query, $link);
$query = "delete from table2 where userid = " . $ID;
$result = mysql_query($query, $link);
...
But even with only 10 members, the page takes 30-60 seconds to come back to
me. What is the best way to accomplish this? And it is possibe to delete
1000 by 1000 or 100 by 100?
Thanks.