Search code examples
google-cloud-platformgoogle-cloud-spanner

Left Join performance on Spanner


We encountered with a disturbing issue. Seems that when we are using left join on the Google Spanner it suffers from bad performance.

The left join operator cause to full scan on the right tables rows from some reason...

Anyone else encountered with this? Of course that when we're removing the left join operator and just using inner join the performance is good...

Execution Plan:

enter image description here


Solution

  • So, it appears that we needed to tell the Google Spanner how to conduct the join operation. In our case APPLY_JOIN did the trick: https://cloud.google.com/spanner/docs/reference/standard-sql/query-syntax#join_hints

    JOIN@{JOIN_TYPE=APPLY_JOIN}