Is it more efficient to always run a delete query, or to check if that information exists first

Posted by Scarface on Stack Overflow See other posts from Stack Overflow or by Scarface
Published on 2010-04-09T03:13:55Z Indexed on 2010/04/09 3:23 UTC
Read the original article Hit count: 384

Filed under:
|

Ok this is going to seem like a dumb question to experienced developers, but questions like this bother me until I ask them. So... is it more efficient to always run a delete query by default whether an entry exists or not, for example to delete a user name after a certain period of time (DELETE * from table where username=user), or should you check if that entry exists first using a select query and mysql_num_rows. What uses more processor on the server side? Obviously one approach contains more code, but I was wondering if certain mysql operations used a lot more cpu than others.

© Stack Overflow or respective owner

Related posts about mysql

Related posts about php