As long as the foreign keys are index it should be pretty quick. There really is no way to get around processing every record in table "data". As that table grows, your query will get slower. But a 157K rows isn't really a whole lot.

How long does it take? Obviously you would want to run SELECT COUNT(*) instead of DELETE. That will tell you how long it will take and how many records will be deleted. You can also slap EXPLAIN in front to see how MySQL will go about executing the query.

On Wednesday, February 5, 2003, at 10:27 AM, Andy Smith wrote:

I wish to delete every row from data which is NOT referenced in
tables t1 and t2.  The manual seems to suggest doing a three table
left join and matching on both t1.data_id and t2.data_id being NULL.
I am concerned this would take way too long, though I can get away
with only doing this query say once a week.
--
Brent Baisley
Systems Architect
Landover Associates, Inc.
Search & Advisory Services for Advanced Technology Environments
p: 212.759.6400/800.759.0577


---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to