2
votes

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?

2

2 Answers

5
votes

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.

1
votes

@samiz - you answer "recommend keeping a sharded counter updated transactionally with changes to the table"

how can we detect how many sharded counter need for the table? there is no retry n transaction...

thank you