WildCard vs all Columns listing - Performance difference

  • 1. If you need all the rows in a table, which provides a lower execution cost?

    Selecting * from a particular table that is well indexed (SELECT * FROM tbEmployees)

    OR

    Specifically selecting each column (SELECT fname, lname, deptId FROM tbEmployees)

    :smooooth:- f

  • Firemander (6/8/2016)


    1. If you need all the rows in a table, which provides a lower execution cost?

    Selecting * from a particular table that is well indexed (SELECT * FROM tbEmployees)

    OR

    Specifically selecting each column (SELECT fname, lname, deptId FROM tbEmployees)

    :smooooth:- f

    Row or columns?

    For quick check queries, I will use the *, but in production code I will explicitly name the columns. Naming the columns ensures that the data will be in same format regardless of changes to the underlying table where the dropping and adding of columns could result in difference between SELECT * and SELECT <columnlist>.

    Performance wise, there shouldn't be a noticeable difference between them.

  • :w00t: Columns; 'you need all the columns' - sorry about that.

  • Response removed as a result of the change from 'rows' to 'columns'!

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • :w00t: I thought that was a question!... with a typo! I clarified the typo - something you can't always do: You know, like using DELETE rather than SELECT and wiping out your employee records. Its a small typo, but you can't get it back; though you can get your final paycheck.

    But this, this was reversible! That's why the author gets to use the 'Post Reply' button. So if he screwed up. He can unscrew. So, please leave the post up... and put away the screwdriver.

    :crazy:..and man, that is one UGLY avatar you got there... :crazy:

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply