0

If i have a database its columns like that

[id  -  col1  -  col2  -  col3]

If i wanted to retrieve all the data to use it ALL, Is it better to use

SELECT * FROM table

or

SELECT id, col1, col2, col3 FROM table

And if there is a difference, Why so?

And in case i'm not going to use the id col is it still better to use

SELECT col1, col2, col3 FROM table

instead of

SELECT * FROM table
Calibur Victorious
  • 638
  • 1
  • 6
  • 20
  • The main difference would be a smaller payload if you didn't need everything, but since you said you wanted all then it doesn't matter. – Jonathan Apr 15 '17 at 13:32
  • @Augwa in which case it would be a smaller payload? And i updated the question. – Calibur Victorious Apr 15 '17 at 13:33
  • The 'payload' is the amount of data the database needs to send back. So, if you don't select all columns the payload is smaller. – KIKO Software Apr 15 '17 at 13:34
  • @KIKOSoftware but isn't it the same if i just typed all the columns to be `SELECT`ed? – Calibur Victorious Apr 15 '17 at 13:36
  • Yes, in my opinion that would be virtually the same. If you want to know: TEST IT. The best way to learn is to practice. So don't ask question and forget the answers, but try and fail, then try again. If you have tested things yourself you'll remember them much better. – KIKO Software Apr 15 '17 at 13:36

0 Answers0