Which is faster/best? SELECT * or SELECT col1, col2,......colN

0 votes
Sep 27 in Database by Daric
• 500 points
14 views

1 answer to this question.

0 votes

There are four big reasons that select * is a bad thing:

  1. The most significant practical reason is that it forces the user to magically know the order in which columns will be returned. It's better to be explicit, which also protects you against the table changing, which segues nicely into...

  2. If a column name you're using changes, it's better to catch it early (at the point of the SQL call) rather than when you're trying to use the column that no longer exists (or has had its name changed, etc.)

  3. Listing the column names makes your code far more self-documented, and so probably more readable.

  4. If you're transferring over a network (or even if you aren't), columns you don't need are just waste.

answered Sep 27 by Omaiz
• 560 points

Related Questions In Database

0 votes
1 answer

Which one is suitable for real time big database- Primary Key or Unique Index?

What is a unique index? A unique index ...READ MORE

answered Oct 12, 2018 in Database by Frankie
• 9,810 points
37 views
0 votes
1 answer

Is SELECT * harmful in Database?

There are really three major reasons: Inefficiency in ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,130 points
45 views
0 votes
1 answer

Which operator is used in the query for pattern matching?

LIKE operator is used for pattern matching, ...READ MORE

answered Oct 15, 2018 in Database by DataKing99
• 8,130 points
44 views
0 votes
1 answer

What is SELECT DISTINCT statement

This statement is used to return only ...READ MORE

answered Nov 21, 2018 in Database by darklord
• 6,150 points
39 views
0 votes
1 answer

What is the syntax of SELECT statement?

This statement is used to select data ...READ MORE

answered Nov 27, 2018 in Database by darklord
• 6,150 points
36 views
0 votes
1 answer

what is the syntax of OR statement in MySQL?

The OR operator displays those records which ...READ MORE

answered Nov 30, 2018 in Database by darklord
• 6,150 points
48 views
0 votes
1 answer

What is the best way to fetch data from table?

Hey Shraddha, I understand your doubts about fetching ...READ MORE

answered May 24 in Database by sampriti
• 1,100 points
36 views
0 votes
2 answers

Why is SELECT * table_name; is considered harmful?

Hi. Adding to @Tina's answer, there is ...READ MORE

answered Sep 23 in Database by Raghu
26 views
0 votes
1 answer

Why is SELECT * considered harmful?

If you add fields to the table, ...READ MORE

answered Sep 27 in Database by Omaiz
• 560 points
25 views
0 votes
1 answer

Which is better database vs. flat files?

Difference between database and flat files are ...READ MORE

answered 2 days ago in Database by Omaiz
• 560 points
6 views