Sorry in advance if this is already on your radar! I looked through the open issues but didn't see anything.
I was trying to use with_pg_search_highlight recently and was confused by how slow it made my queries. I expected ts_headline to make the search slower, so I paginated my results, but it didn't seem to make a difference one way or another. Eventually I realized that ts_headline was being applied to every result, rather than just the page of them. I ended up writing the SQL myself instead of using pg_search and the performance improved when using ts_headline by almost an order of magnitude.
My pg_search queries looked something like this:
Story.search_text_for("dog").limit(20).offset(0).with_pg_search_highlight
Where search_text_for was a pg_search_scope (I wasn't using multisearch if it makes a difference).
Is there a reason that you apply the highlighting to every row? Or is there a way to paginate that I just wasn't aware of?
Thanks!
Sorry in advance if this is already on your radar! I looked through the open issues but didn't see anything.
I was trying to use
with_pg_search_highlightrecently and was confused by how slow it made my queries. I expectedts_headlineto make the search slower, so I paginated my results, but it didn't seem to make a difference one way or another. Eventually I realized thatts_headlinewas being applied to every result, rather than just the page of them. I ended up writing the SQL myself instead of usingpg_searchand the performance improved when usingts_headlineby almost an order of magnitude.My
pg_searchqueries looked something like this:Where
search_text_forwas apg_search_scope(I wasn't usingmultisearchif it makes a difference).Is there a reason that you apply the highlighting to every row? Or is there a way to paginate that I just wasn't aware of?
Thanks!