Skip to content

Commit 1e59334

Browse files
committed
Revert "store: Speed queries of type A up by adding a redundant clause"
In production, this change actually slows queries that look up a large number of children (500+) down tremendously; could be because evaluating the clause 'c.{parent_field} && {parent_ids}' becomes very slow with a large number of parent ids. This reverts commit e566447.
1 parent 70c4b55 commit 1e59334

File tree

1 file changed

+0
-8
lines changed

1 file changed

+0
-8
lines changed

store/postgres/src/relational_queries.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,12 +1631,8 @@ impl<'a> FilterWindow<'a> {
16311631
// from unnest({parent_ids}) as p(id),
16321632
// children c
16331633
// where c.{parent_field} @> array[p.id]
1634-
// and c.{parent_field} && {parent_ids}
16351634
// and .. other conditions on c ..
16361635
// 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)`
16401636

16411637
out.push_sql("\n/* child_type_a */ from unnest(");
16421638
column.bind_ids(&self.ids, out)?;
@@ -1648,10 +1644,6 @@ impl<'a> FilterWindow<'a> {
16481644
out.push_sql(" and c.");
16491645
out.push_identifier(column.name.as_str())?;
16501646
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)?;
16551647
self.and_filter(out.reborrow())?;
16561648
limit.single_limit(self.ids.len(), out);
16571649
Ok(())

0 commit comments

Comments
 (0)