Is there a performance gain achieved by using:
SELECT Field1, Field2, Field3 ...
instead of:
SELECT * ...
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If the list field1, ….. represents a sub set of the available columns then the answer is yes. How much more efficient depends on how much smaller the subset is.
For each row processed there are a number of “per column” operations depending on the column type this can be as little as re-alinging bytes to an integer boundry or as heavy as allocating suitable chunck of memory and reading in a large BLOB from another file.
However most seasoned programmers will always code a specificic column list even if there are little or no performance benefits. There are a couple of reasons the most important being that it helps insulate your program from changes in the datatbase schema — your program will not blow up in someone adds or reorders columns, secondly is readability you dont need to keep going back to the DB schema to see what your program is getting from the table, and thirdly it helps with impact analysis as you can scan your source code for usage of particular columns.