0

Suppose I have a table with columns id, name, contact.

What difference is there by getting the data with

SQL query #1:

SELECT * 
FROM table

and SQL query #2:

SELECT id, name, contact 
FROM table
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
xerex09
  • 166
  • 14
  • For the moment - there is no difference. But if you happen to add a blob column to your table later, that contains **a lot** of binary data (images etc.) - then query #1 will be slowing down to a crawl (since it will also be retrieving that blob column), while #2 will remain quick and fast – marc_s Dec 18 '18 at 05:53
  • 1
    In addition to Marc's comment above, read the duplicate link for a handful of other reasons _not_ to ever use `SELECT *` in your code. – Tim Biegeleisen Dec 18 '18 at 05:56

1 Answers1

0

SELECT * FROM table - its will select all column even if those are useful or not. if you selecting all the column than some memory overhead and time consuming. For example , suppose you are selecting all the column and storing in some java object then this is not useful instead of this select those column which is useful for your operation.

  • I am retrieving all the data by both the query. All data are to be used. But the DBA says there is difference in performance and data return. So was curious with the question – xerex09 Dec 18 '18 at 05:57
  • For DBA point of view they also suggest to add query hint according to the query execution cost.if you are using todd than you can check execution cost via CTl+E – sant prajapati Dec 18 '18 at 07:10