Options

Which query is faster, select count(*) or count(pk)?

HyeontaeJuHyeontaeJu Vertica Customer
edited November 2021 in General Discussion

Which query is faster, select count(*) or count(pk)?

Answers

  • Options
    verbanverban Vertica Customer
    edited November 2021

    Definitely select count(1) is too much faster,
    The count(pk) is equal to select count(1) where pk is not null,
    In my case select count(1) takes 200ms but the select count(id) takes more than 20 seconds (the table has more than 10B records)!
    Also i think select count(1) and select count(*) are same

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file