Forum Moderators: coopster

Message Too Old, No Replies

DELETE TimeOut issue on a Large Database

         

HoboTraveler

3:08 pm on Oct 10, 2006 (gmt 0)

10+ Year Member



Hi All,

When I run the script below, it results in a timeout. Running the commands through phpMyAdmin, results in a timeout too.

Table1 has 40,000 records and Table2 has 35,000 records. I run the script to get rid of the duplicates.

Is there a way that I can check for duplicates without the timeout issue?

I tried the while loop through PHP and that results in a timeout too..

TIA

-- begin code --

DELETE
FROM
table1
WHERE
table1.email
IN
(
SELECT
emailAddress
FROM
table2
WHERE
emailAddress = table1.email
)

Scally_Ally

4:01 pm on Oct 10, 2006 (gmt 0)

10+ Year Member



i think maybe it is because the script is still searching through your query and not yet finished before the timeout. Because table 2 is being searched for every record of table 1 (40,000 * 35,000) its gonna take a while to complete.

I always try and make sure i have good indexes on my columns that are being searched, that speeds things up.

Failing that get yourself a MySQL GUI so you can run sql commands through there without the browser timing out, or if you have access to the mysql command line on the server then run your sql through there.

Hope this helps.

HoboTraveler

5:13 pm on Oct 10, 2006 (gmt 0)

10+ Year Member



Hello,

I do have the indexes and all.. I am thinking of doing a LIMIT 300 so the timeout issue may not occur..