Appropriate index for query with unnest

Same issue. I would recommend leave distance in projection to avoid unnecessary calculation. The above optimization is all or nothing (i.e even one let variable used in WHERE it will compute before WHERE).

1 Like