File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -1631,8 +1631,12 @@ impl<'a> FilterWindow<'a> {
1631
1631
// from unnest({parent_ids}) as p(id),
1632
1632
// children c
1633
1633
// where c.{parent_field} @> array[p.id]
1634
+ // and c.{parent_field} && {parent_ids}
1634
1635
// and .. other conditions on c ..
1635
1636
// limit {parent_ids.len} + 1
1637
+ //
1638
+ // The redundant `&&` clause helps Postgres to narrow down the
1639
+ // rows it needs to pick from `children` to join with `p(id)`
1636
1640
1637
1641
out. push_sql ( "\n /* child_type_a */ from unnest(" ) ;
1638
1642
column. bind_ids ( & self . ids , out) ?;
@@ -1644,6 +1648,10 @@ impl<'a> FilterWindow<'a> {
1644
1648
out. push_sql ( " and c." ) ;
1645
1649
out. push_identifier ( column. name . as_str ( ) ) ?;
1646
1650
out. push_sql ( " @> array[p.id]" ) ;
1651
+ out. push_sql ( " and c." ) ;
1652
+ out. push_identifier ( column. name . as_str ( ) ) ?;
1653
+ out. push_sql ( " && " ) ;
1654
+ column. bind_ids ( & self . ids , out) ?;
1647
1655
self . and_filter ( out. reborrow ( ) ) ?;
1648
1656
limit. single_limit ( self . ids . len ( ) , out) ;
1649
1657
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments