Thursday, February 5, 2015

count(*) is faster than count(1) - no more with nine.four

In PostgreSQL 9.4, count(1) speed is equally fast to count(*).

Another reason to upgrade to 9.4.

count(<column>) is still slower if no index is used...

3 comments:

  1. I've been trying this on PG 9.4 and here I get that count(*) is consistently slightly faster than count(1).

    ReplyDelete
  2. Actually, now I'm finding that they are about the same. On PG 9.4

    ReplyDelete
  3. count() can be faster if we enfore index to use but not extra ordinary benefits. I have tested with very high volume about 130000000 rows.

    ReplyDelete