MySql Selecting All (speed)

Discussion in 'PHP' started by Giber, Jul 28, 2009.

  1. #1
    Is there any difference in data retrieve speed if
    I select only specified fields in the query instead
    of using asterisk for selecting all?

    "select name,date"

    or

    "select *"

    Which is faster?

    Note, that I need to output only two fields of 10!

    Is there any difference?

    Thank You for any advice.
     
    Giber, Jul 28, 2009 IP
  2. zandigo

    zandigo Greenhorn

    Messages:
    71
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    There will not significant difference of your database is not huge. However, when you dealing with thousands of thousand rows, there will be the problem.

    In all case, only select fields that is needed, minimal resource used is always preferable.
     
    zandigo, Jul 28, 2009 IP
  3. Steve136

    Steve136 Peon

    Messages:
    240
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,

    Like zandigo pointed out, large databases will be much slower as you're fetching every field from the table.

    Make sure to only select the data you wish to use and that the table has proper indexes to make selecting quicker.

    Regards,

    Steve
     
    Steve136, Jul 29, 2009 IP
  4. Giber

    Giber Well-Known Member

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #4
    That was exactly what I needed to know about!

    My database does not have a lot of fields,

    but for me every millisecond counts.

    Thank You
     
    Giber, Jul 29, 2009 IP