0

COUNT(id): query cost: 463

count id

COUNT(*): query cost: 91.47

count *

Can someone help me to understand why COUNT(id) is more expensive than COUNT(*)?

Tony Dinh
  • 6,668
  • 5
  • 39
  • 58
  • 3
    `Count(*) counts all rows` , And `COUNT(column) counts non-NULLs only ` and have to access every row to see if the value is null or not See this post [count(*) vs count(column-name)](https://stackoverflow.com/questions/3003457/count-vs-countcolumn-name-which-is-more-correct) – Yagami Light Aug 20 '17 at 09:30
  • What is the cost if you have a "covering index": `INDEX(song_id, id)` – Rick James Aug 21 '17 at 18:30

0 Answers0