Nhoj Posted December 31, 2006 Share Posted December 31, 2006 I've got a database with well over 500,000 users all stored in a table named `users`. The table itself has around 20 - 25 columns with some information stored in each column such as e-mail etc. The primary column is called 'id' and it's stored as an unsigned int(11) with auto incrementing.I was wondering, if I am updating my database and only update 1 users information at a time based on their ID would the "LIMIT 1" argument help increase load time or reduce any overhead?For example, would running [code=php:0]mysql_query('UPDATE `users` SET `uAddress` = "'.$_POST['uAddress'].'" WHERE `uID` = '.$uID.' LIMIT 1');[/code]be any faster than running[code=php:0]mysql_query('UPDATE `users` SET `uAddress` = "'.$_POST['uAddress'].'" WHERE `uID` = '.$uID);[/code]Thanks,John Quote Link to comment Share on other sites More sharing options...
fenway Posted December 31, 2006 Share Posted December 31, 2006 With a UID, limit 1 is redundant. Quote Link to comment Share on other sites More sharing options...
hvle Posted January 3, 2007 Share Posted January 3, 2007 even though it might be redundant, you should place limit to every update and delete statements. It added another shield to protect your data. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 3, 2007 Share Posted January 3, 2007 I disagree... there's no reason to protect a primary key. Quote Link to comment Share on other sites More sharing options...
hvle Posted January 4, 2007 Share Posted January 4, 2007 You are absolutely right, but it is a good coding pratice to have limit 1 on update and delete queries. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 5, 2007 Share Posted January 5, 2007 IMHO, I don't like LIMIT 1 where it's not really needed, because it allows for poor queries to be go unnoticed. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.