only join strings once
Ted Unangst tedu@tedunangst.com
Wed, 30 Oct 2019 03:36:28 -0400
1 files changed,
5 insertions(+),
3 deletions(-)
jump to
M
database.go
→
database.go
@@ -372,8 +372,9 @@ for _, h := range honks {
ids = append(ids, fmt.Sprintf("%d", h.ID)) hmap[h.ID] = h } + idset := strings.Join(ids, ",") // grab donks - q := fmt.Sprintf("select honkid, donks.fileid, xid, name, description, url, media, local from donks join filemeta on donks.fileid = filemeta.fileid where honkid in (%s)", strings.Join(ids, ",")) + q := fmt.Sprintf("select honkid, donks.fileid, xid, name, description, url, media, local from donks join filemeta on donks.fileid = filemeta.fileid where honkid in (%s)", idset) rows, err := db.Query(q) if err != nil { log.Printf("error querying donks: %s", err)@@ -394,7 +395,7 @@ }
rows.Close() // grab onts - q = fmt.Sprintf("select honkid, ontology from onts where honkid in (%s)", strings.Join(ids, ",")) + q = fmt.Sprintf("select honkid, ontology from onts where honkid in (%s)", idset) rows, err = db.Query(q) if err != nil { log.Printf("error querying onts: %s", err)@@ -413,8 +414,9 @@ h := hmap[hid]
h.Onts = append(h.Onts, o) } rows.Close() + // grab meta - q = fmt.Sprintf("select honkid, genus, json from honkmeta where honkid in (%s)", strings.Join(ids, ",")) + q = fmt.Sprintf("select honkid, genus, json from honkmeta where honkid in (%s)", idset) rows, err = db.Query(q) if err != nil { log.Printf("error querying honkmeta: %s", err)