$ gcloud spanner databases execute-sql --project=${PROJECT_ID} --instance=${INSTANCE_ID} ${DATABASE_ID} \
--sql "$(cat input.sql)" --query-mode=PLAN --format=json | jq -r -f plan.jq
*0 Distributed Union
*1 Distributed Cross Apply
2 Create Batch
3 Local Distributed Union
4 Compute Struct
*5 FilterScan
6 Index Scan (Index: SongsBySongName)
24 [Map] Serialize Result
25 Cross Apply
26 Batch Scan (Batch: $v2)
31 [Map] Local Distributed Union
*32 FilterScan
33 Table Scan (Table: Songs)
Predicates:
0: Split Range: (STARTS_WITH($SongName, 'A') AND REGEXP_CONTAINS($SongName, '^A.*z'))
1: Split Range: ($Songs_key_SingerId' = $Songs_key_SingerId)
5: Seek Condition: STARTS_WITH($SongName, 'A')
Residual Condition: REGEXP_CONTAINS($SongName, '^A.*z')
32: Seek Condition: (($Songs_key_SingerId' = $batched_Songs_key_SingerId) AND ($Songs_key_AlbumId' = $batched_Songs_key_AlbumId)) AND ($Songs_key_TrackId' = $batched_Songs_key_TrackId)
$ gcloud spanner databases execute-sql --project=${PROJECT_ID} --instance=${INSTANCE_ID} ${DATABASE_ID} \
--sql "$(cat input2.sql)" --query-mode=PLAN --format=json | jq -r -f plan.jq
*0 Distributed Union
1 Local Distributed Union
2 Serialize Result
3 Table Scan (Full scan: true, Table: Singers)
14 [Scalar] Array Subquery
15 Local Distributed Union
16 Compute Struct
*17 FilterScan
18 Table Scan (Table: Albums)
31 [Scalar] Array Subquery
32 Local Distributed Union
33 Compute Struct
*34 FilterScan
35 Table Scan (Table: Songs)
Predicates:
0: Split Range: true
17: Seek Condition: ($SingerId_1 = $SingerId)
34: Seek Condition: (($SingerId_2 = $SingerId_1) AND ($AlbumId_1 = $AlbumId))