From: fiala_marek@centrum.cz
To: pgsql-performance@postgresql.org
Subject: Search query is curious
Date: Tue, 17 Aug 2010 09:26:19 +0200
Message-ID: <1282029979.831570.27725.nullmailer@mail1002.cent> (raw)
Hi,
I've database of lyrics and I'm using this query for suggest box.
SELECT views, title, id FROM songs WHERE title ILIKE 'bey%' ORDER BY views DESC LIMIT 15;
In query plan is this line: -> Seq Scan on songs (cost=0.00..11473.56 rows=5055 width=23) (actual time=1.088..89.863 rows=77 loops=1)
it takes about 90ms
but when i modify query (remove sort)
SELECT views, title, id FROM songs WHERE title ILIKE 'bey%' LIMIT 15;
In query plan -> Seq Scan on songs (cost=0.00..11473.56 rows=5055 width=23) (actual time=1.020..20.601 rows=15 loops=1
seq scan takes only 20ms now, why?
Or any suggestion to optimize this query?
In table songs are about 150.000 rows.
Thank you for your reply.
Best regards.
Marek Fiala
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: fiala_marek@centrum.cz
Subject: Re: Search query is curious
In-Reply-To: <1282029979.831570.27725.nullmailer@mail1002.cent>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox