我在Spanner中有以下查询优化问题,并希望有一个我缺少的技巧,这将帮助我将查询规划器弯曲到我的意愿.
这是简化的架构:
create table T0 (
key0 int64 not null,
value int64,
other int64 not null,
) primary key (key0);
create table T1 {
key1 int64 not null,
other int64 not null
} primary key (key1);
Run Code Online (Sandbox Code Playgroud)
并在IN子句中使用子查询进行查询:
select value from T0 t0
where t0.other in (
select t1.other from T1 t1 where t1.key1 in (42, 43, 44) -- note: this subquery is a good deal more complex than this
)
Run Code Online (Sandbox Code Playgroud)
通过T0的散列连接与子查询的输出生成10个元素集:
Operator Rows Executions
----------------------- ----- ----------
Serialize …Run Code Online (Sandbox Code Playgroud)