Skip to content

Commit

Permalink
feat: add indexes for searches
Browse files Browse the repository at this point in the history
Signed-off-by: Guillaume Hivert <[email protected]>
  • Loading branch information
ghivert committed May 14, 2024
1 parent c863357 commit 5162a41
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
-- migrate:up
create index package_type_fun_signature_name on package_type_fun_signature (name);
create index package_type_fun_signature_signature on package_type_fun_signature using gin (to_tsvector('english', signature_));

-- migrate:down
drop index package_type_fun_signature_name;
drop index package_type_fun_signature_signature;
2 changes: 1 addition & 1 deletion apps/backend/src/backend/postgres/queries.gleam
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ pub fn search(db: pgo.Connection, q: String) {
ON r.id = m.package_release_id
JOIN package p
ON p.id = r.package_id
WHERE to_tsvector(s.signature_) @@ to_tsquery($1)
WHERE to_tsvector('english', s.signature_) @@ to_tsquery($1)
LIMIT 40"
|> pgo.execute(db, [query], decode_type_search)
|> result.map_error(error.DatabaseError)
Expand Down

0 comments on commit 5162a41

Please sign in to comment.