I have a large number of records indexed on some startDateTime
field, and want to select aggregates (SUM and COUNT) on all records grouped by WEEKOFYEAR(startDateTime)
(i.e., EXTRACT(WEEK FROM startDateTime)
). Can I put a secondary index on EXTRACT(WEEK FROM startDateTime)
? Or, even better, will the query use an index on startDateTime
appropriately to optimize a request grouped by WEEK?
See this similar question about MySQL indices. How would this be handled in the Cloud Spanner world?