Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud spanner: select count * takes over a minute

I created a test table in cloud spanner and populated it with 120 million rows. i have created a composite primary key for the table.

when i run a simple "select count(*) from " query, it takes approximately a minute for cloud spanner web UI to return results.

Is anyone else facing similar problem?

like image 370
Shailu Mishra Avatar asked Sep 06 '25 10:09

Shailu Mishra


1 Answers

Cloud Spanner does not materialize counts, so queries will like "select count(*) ...." will scan the entire table to return the count of rows, hence the higher time to execute. If you require faster counts, recommend keeping a sharded counter updated transactionally with changes to the table.

like image 168
samiz Avatar answered Sep 11 '25 04:09

samiz