Click here to Skip to main content
15,891,607 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Greetings,

i want to know, if its better to specify the columns in selecting in a table rather than using a select * in a table, will i have faster searching or retrieval of records if i will specify the columns i need in a query?
what is the disadvantage of using select * in a table and advantage of selecting the specified columns in a table,

Please help me on this, I really need an concrete answer to my question, it will help me a lot in constructing my code, also i want my query to have good retrieval and connection to my database,

Thank you..
Posted

1 solution

It is better to specify the columns rather than using *. One reason is the query engine can optimize the query better knowing what the columns and types are rather than having to take a guess with a broad *. This can be particularly important when using tables that are broad, or when using multiple tables in a query. With this information a more optimized and possibly efficinet TDS can be formed and sent to the requesting agent.

Another reason is for code readability and maintenance; you will know specifically which columns are used.
 
Share this answer
 
Comments
[no name] 19-May-11 3:45am    
Thanks for your answer Mark, it helps me a lot ^^
Kim Togo 19-May-11 5:54am    
Good answer, 5.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900