0

I have a secondary index on a table:

CREATE NULL_FILTERED INDEX RidesByPassenger ON Rides(
  passenger_id,
  start_time,
)

If I run the following query:

SELECT start_time FROM Rides@{FORCE_INDEX=RidesByPassenger}
WHERE passenger_id='someid' AND start_time IS NOT NULL;

Can I be sure the base table won't be accessed for it? In other words, if I query a secondary index using only the first part of the primary key (in this case passenger_id), will it use only the secondary index? Or the base table as well? Also, is there a way to ask Spanner exactly which tables it's accessing when I run a query?

Dan McGrath
  • 41,220
  • 11
  • 99
  • 130
Chi
  • 259
  • 3
  • 11

1 Answers1

2

Since this query only uses columns that are covered by the index, it will not join the base table. You can always run (EXPLAIN/PROFILE SQL_QUERY for the query plan) in gcloud tool to be sure.

Chi
  • 259
  • 3
  • 11