Web Analytics Made Easy -
StatCounter MySQL query or fread? - CodingForum

Announcement

Collapse
No announcement yet.

MySQL query or fread?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    or
    b) fopen-ing a file and fread-ing it (both binary; 80 chars); also 20 entries.

  • #2
    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
    OracleGuy

    Comment

    Working...
    X
    😀
    🥰
    🤢
    😎
    😡
    👍
    👎