...

View Full Version : MySQL query or fread?



Apothem
09-06-2011, 11:37 PM
So lets say my script always connects to the MySQL database at beginning of script.

Now, what would be faster to obtain data?
a) Selecting all data from a table with 20 entries
or
b) fopen-ing a file and fread-ing it (both binary; 80 chars); also 20 entries.

oracleguy
09-06-2011, 11:41 PM
Depends but if MySQL has the query cached it could be a lot faster. You can time PHP code, your best bet would be to write both and time them. Does any other parts of the page require data from your database? If so the connection time is going to be a cost either way.

For timing your code see: http://php.net/manual/en/function.microtime.php



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum