Skip to content

Commit

Permalink
sql: optimize search
Browse files Browse the repository at this point in the history
  • Loading branch information
astro committed Nov 23, 2012
1 parent 250ebe3 commit e8842db
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pg_search.sql
Expand Up @@ -2,7 +2,7 @@

-- search feeds
ALTER TABLE feeds ADD COLUMN search tsvector;
CREATE INDEX search_feeds ON feeds USING gist(search);
CREATE INDEX search_feeds ON feeds USING gin(search);

CREATE OR REPLACE FUNCTION search_feeds_trigger() RETURNS trigger AS $$
DECLARE
Expand Down Expand Up @@ -104,7 +104,7 @@ CREATE OR REPLACE FUNCTION search_feed_items(
COALESCE(downloaded_stats.downloaded, 0) AS "downloaded"
FROM (SELECT * FROM feed_items
WHERE "search" @@ "query"
ORDER BY ts_rank(feed_items."search", "query") DESC
ORDER BY "published" DESC
LIMIT "limit" OFFSET "offset"
) AS feed_items
JOIN feeds ON (feed_items.feed=feeds.url)
Expand Down

0 comments on commit e8842db

Please sign in to comment.