Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: MySQL query or fread?
09-06-2011, 10:37 PM #1
MySQL query or fread?
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
b) fopen-ing a file and fread-ing it (both binary; 80 chars); also 20 entries.
09-06-2011, 10:41 PM #2
- Join Date
- Jun 2002
- Thanked 328 Times in 324 Posts
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.phpOracleGuy