Which is most efficient please

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • barrypalmer
    New Member
    • Oct 2007
    • 9

    #1

    Which is most efficient please

    I have a DB with 100K records
    I need to pull out ONE records at a time for processing

    I say SELECT * FROM table WHERE done=0 LIMIT 1;

    Since the records have 30+ fields (some large) would it be better to say

    SELECT id FROM table WHERE done=0 LIMIT 1;
    and then do another SELECT * for this 'id'

    Just thinking of mySQL holding all that data just to throw it all away again for the LIMIT 1
  • amitpatel66
    Recognized Expert Top Contributor
    • Mar 2007
    • 2358

    #2
    Originally posted by barrypalmer
    I have a DB with 100K records
    I need to pull out ONE records at a time for processing

    I say SELECT * FROM table WHERE done=0 LIMIT 1;

    Since the records have 30+ fields (some large) would it be better to say

    SELECT id FROM table WHERE done=0 LIMIT 1;
    and then do another SELECT * for this 'id'

    Just thinking of mySQL holding all that data just to throw it all away again for the LIMIT 1
    If you want all the columns data then say SELECT * FROM instaed of SELECT id FROM

    Comment

    • ronverdonk
      Recognized Expert Specialist
      • Jul 2006
      • 4259

      #3
      You did not state if you are using index. Use the EXPLAIN SELECT ... statement and compare the resource usage results. On that basis you can decide what query is most efficient.

      Ronald

      Comment

      Working...