0

My Table has only 2 Columns

`Select * from table` ----Execution time 10 second
Select name,mobile from table--Execution time 5 second
TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
solanki kaushik
  • 521
  • 1
  • 4
  • 5
  • 1
    Cached table data? (Try the opposite order.) – jarlh Aug 02 '16 at 10:35
  • 2
    check out this post in this same forum http://stackoverflow.com/questions/3180375/select-vs-select-column – BytesOfMetal Aug 02 '16 at 10:36
  • http://stackoverflow.com/questions/65512/which-is-faster-best-select-or-select-column1-colum2-column3-etc http://stackoverflow.com/questions/3180375/select-vs-select-column – Avishek Aug 02 '16 at 10:38

2 Answers2

0

Select * and Select Columns doesn't have any differences when you are scanning the whole table..

Below differences can crop up when you use unnecessary columns

1.Scan of whole another table due to Rowlookup cost exceeding limit
2.Sending data over network

In your case the difference can be due to locking,blocking,memory pressure...whole lot of reasons..but not due to expanding all columns vs *

Excerpt from Conor cunningham on the same..

TheGameiswar
  • 27,855
  • 8
  • 56
  • 94
0

Did you do 'select *', then 'select name, mobile' right after ? If yes, then it's warm caching. Your data is in memory. The second query runs faster.

librata
  • 150
  • 9