Skip site navigation (1) Skip section navigation (2)

Search query is curious

From: <fiala_marek(at)centrum(dot)cz>
To: <pgsql-performance(at)postgresql(dot)org>
Subject: Search query is curious
Date: 2010-08-17 07:26:19
Message-ID: 1282029979.831570.27725.nullmailer@mail1002.cent (view raw or flat)
Thread:
Lists: pgsql-performance
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

Responses

pgsql-performance by date

Next:From: Greg SmithDate: 2010-08-17 08:29:10
Subject: Re: Advice configuring ServeRAID 8k for performance
Previous:From: Tom LaneDate: 2010-08-17 03:33:29
Subject: Re: Quesion on the use of indexes

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group