MYSQL Performance diff

Hi, does anyone know how much more efficient would selecting a few rows out of lets say a 1000 using the where int clause rather than using a where varchar(25) clause. <br />Both indexed of course. <br /><br />Would this be a drastic increase in efficiency or not?<br /><br />thanks,<br />Dave<!--content-->
I believe it would be more efficient, but by HOW MUCH... only a test could tell.<br /><br />There are timing scripts you can plug into your pages to give you a rough estimate of how long they take to execute.<br /><br />from php.net<br /><br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec--><?php<br /><br />function getmicrotime() {<br />  list($usec, $sec) = explode(" ", microtime());<br />  return ((float)$usec + (float)$sec);<br />}<br /><br />$time_start = getmicrotime();<br />  <br />for ($i=0; $i < 1000; $i++){<br />  // do nothing, 1000 times<br />}<br /><br />$time_end = getmicrotime();<br />$time = $time_end - $time_start;<br /><br />echo "Did nothing in $time seconds\n";<br /><br />// with PHP 5 you can do the same this way:<br /><br />$time_start = microtime(1);<br /><br />for ($i=0; $i < 1000; $i++){<br />    // do nothing, 1000 times<br />}<br /><br />$time_end = microtime(1);<br />$time = $time_end - $time_start;<br /><br />echo "Did nothing in $time seconds\n";<br /><br />?><!--QuoteEnd--></div><!--QuoteEEnd--><!--content-->
ya, I have something like that on another script of mine. I guess your right..I'll have to check myself.<!--content-->
I tested it against a few thousand rows and all my tests showed the where varchar to be faster...I find that odd. why is that...you would think it would be easier to search for ints.<!--content-->
I don't know... but I bet you're glad you tested it for yourself. If you had just assumed what you thought you knew... as I did... then you wouldn't have chosen correctly.<br /><br />This is a little reminder to me that I don't know everything and shouldn't take anything for granted.<br /><br />Thanks for reporting your results.<br /><br />By the way, was it drastically faster? Or just slightly?<!--content-->
I did it from 1000 to 5000 rows... and it was only slightly faster.... I didn't calculate the percentage difference which i should have...and I already cleaned out my dummy table. But as I recall it was only like a .0002 seconds faster querying 5000 rows. But every time i ran the script the varchar was always faster.<!--content-->
 
Back
Top