Forum Moderators: coopster

Message Too Old, No Replies

Count vs DELETE Speed

         

HoboTraveler

7:52 am on Oct 11, 2006 (gmt 0)

10+ Year Member



Hi All,

When checking for duplicates between tables, is it quicker to check first, if the match exists in the table through a SELECT and then check the value of mysql_num_rows.

So, if mysql_num_rows > 0 then DELETE the record.

OR is it quicker to directly attempt a DELETE without checking if the match exists..

TIA

eelixduppy

10:45 am on Oct 11, 2006 (gmt 0)



The latter: directly try to delete them.

coopster

1:50 pm on Oct 11, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Exactly, and if you need to know if a row(s) was found so you can report success/failure to the user you can use mysql_affected_rows [php.net].