SELECT COUNT(*) FROM BigTable_1
Which way I should to use to get number of rows in table if I have more than 1 billion of rows?
UPDATE: For example, if we have ‘a timeout problem’ with the query above is there any way to optimize it? How to do it quicker?
If you need an exact count, you have to use
COUNT (*)If you are OK with a rough count, you can use a sum of rows in the partitions
If you want to be funny with your
COUNT, you can do the following