Re: Full text search with ORDER BY performance issue - Mailing list pgsql-performance

From Kevin Grittner
Subject Re: Full text search with ORDER BY performance issue
Date
Msg-id 4A649E7702000025000289E3@gw.wicourts.gov
Whole thread Raw
In response to Full text search with ORDER BY performance issue  (Krade <krade@krade.com>)
Responses Re: Full text search with ORDER BY performance issue  (Krade <krade@krade.com>)
List pgsql-performance
Krade <krade@krade.com> wrote:
> SELECT * FROM a WHERE comment_tsv @@ plainto_tsquery('love')
> ORDER BY timestamp DESC LIMIT 24 OFFSET 0;

Have you considered keeping rows "narrow" until you've identified your
24 rows?  Something like:

SELECT * FROM a
  WHERE id in
    (
      SELECT id FROM a
        WHERE comment_tsv @@ plainto_tsquery('love')
        ORDER BY timestamp DESC
        LIMIT 24 OFFSET 0
    )
  ORDER BY timestamp DESC
;

-Kevin

pgsql-performance by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: Fastest char datatype
Next
From: Tom Lane
Date:
Subject: Re: Calling conventions