One big query vs. lots of small queries

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a question of efficiency.

I have an application in PHP using MySQL.

Users select items on a form and each selected item represents a change in a table row. It is possible that 100s of changes might be chosen from a single form.

Which is likely to be faster/more efficient?

multiple queries like...
$query="UPDATE some_table SET x='$y' WHERE id='$z[$key]'";
$result=mysql_query($query);

or one huge query like...
$query="UPDATE some_table SET x='$y' WHERE id='$z[$key]'
	OR id='$z[$another_key]' OR id='$z[$another_key]
	OR id='$z[$another_key]"; etc?
$result=mysql_query($query);

In the latter, PHP would have to construct the WHERE string, which would require some processing power as well. Is there a limit to how many OR's can be added to a mysql query? No - don't answer that, I'll look in the manual.

Many thanks,

Jeff

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux