it looks like the optimizer is doing table scan instead of index scan if I select column that are not part of the index!.
I created the following table and index
As it was already mentioned in your Stackoverflow question, internal documentation recommends using the directive FORCE INDEX to force the index you want to use, which will increase the consistency of your searches. The query optimizer for Cloud Spanner may take up to 3 days to begin using an index after it has been created since it needs that time to gather the database's information.
Here is the direct link to review more information on Cloud Spanner - Secondary Indexes.
In my case it has already been more than 3 days, instead it's been weeks. But why is index still not being used ?
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |