mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: reduce the number of joins on neighbors without predicates (#154)
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/154 Loading the "form" table is not required where there's no predicate on the join. Reviewed By: alexsn Differential Revision: D18421062 fbshipit-source-id: cb2a045a5a8a76ea4f07e5cf4305a6da338a616e
This commit is contained in:
committed by
Facebook Github Bot
parent
514c0ff6d3
commit
73e294a21e
@@ -78,13 +78,10 @@ func Neighbors(dialect string, s *Step) (q *Selector) {
|
||||
pk1, pk2 = pk2, pk1
|
||||
}
|
||||
to := builder.Table(s.To.Table)
|
||||
from := builder.Table(s.From.Table)
|
||||
join := builder.Table(s.Edge.Table)
|
||||
match := builder.Select(join.C(pk1)).
|
||||
From(join).
|
||||
Join(from).
|
||||
On(join.C(pk2), from.C(s.From.Column)).
|
||||
Where(EQ(from.C(s.From.Column), s.From.V))
|
||||
Where(EQ(join.C(pk2), s.From.V))
|
||||
q = builder.Select().
|
||||
From(to).
|
||||
Join(match).
|
||||
|
||||
Reference in New Issue
Block a user