Combine AND(Fixed, SQL) into a single IN clause, reducing roundtrips. Add a test and benchmark.
This commit is contained in:
parent
99283d5412
commit
277fc748e3
4 changed files with 74 additions and 11 deletions
|
|
@ -224,9 +224,8 @@ func (l *SQLLinkIterator) buildWhere() (string, []string) {
|
|||
q = append(q, fmt.Sprintf("%s.%s_hash = ?", l.tableName, c.dir))
|
||||
vals = append(vals, hashOf(c.vals[0]))
|
||||
} else if len(c.vals) > 1 {
|
||||
subq := fmt.Sprintf("%s.%s_hash IN ", l.tableName, c.dir)
|
||||
valslots := strings.Join(strings.Split(strings.Repeat("?", len(c.vals)), ""), ", ")
|
||||
subq += fmt.Sprintf("(%s)", valslots)
|
||||
subq := fmt.Sprintf("%s.%s_hash IN (%s)", l.tableName, c.dir, valslots)
|
||||
q = append(q, subq)
|
||||
for _, v := range c.vals {
|
||||
vals = append(vals, hashOf(v))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue