Add trigram index for usable note search #409
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Searching notes kinda sucks, I almost never get it to succeed on rarely used terms that would require going through a lot of note history. Adding a trigram index like
CREATE INDEX test_trgm_idx ON note USING GIN (text gin_trgm_ops);has massively improved the speed without needing to rewrite the search query for full-text search, but I'm not sure if/how to add it to the ORM, and what to do about thepg_trgmextension requirement.Improving the search speed was the intention behind adding the ability to restrict which users' notes are searched. And personally I haven't had any trouble finding notes with the search, even though I checked that there is no index on the
note.textcolumn in my database. So in my opinion this is not necessary.As a general suggestion in case you haven't tried that, I would recommend vacuuming (full + analyze) and while you're at it using
pg_repack(even if the latter probably doesn't have anything to do with note text search).Since as you said, no change to the code is needed, I think it can easily be optional. It could be added as an optional thingy in
docs/install.md, which also resolves the question about what to do with the extension requirement you mentioned.FWIW I often don't know/remember what user's notes I want to search, and without setting a user it times out basically every time (unless the search is so generic that it fills the limit fast enough). Full vacuum + analyze doesn't help that much either.
Will look into adding it into some docs though.