pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feedOptimize slow query
3+ messages / 2 participants
[nested] [flat]
* Optimize slow query
@ 2007-06-13 11:41 Tyler Durden <tylersticky@gmail.com>
0 siblings, 2 replies; 3+ messages in thread
From: Tyler Durden @ 2007-06-13 11:41 UTC (permalink / raw)
To: pgsql-performance
Hi,
I've a table with 300 000 records and I'm trying to do a search:
SELECT * FROM addresses WHERE address ILIKE '%Jean Paul%' AND
(l_pc='4250' or r_pc='4250') AND (l_struc='O' or r_struc='O') AND
(prenm ILIKE 'Street')
It performs in 2 seconds in a dual Xeon 2.4mhz with 2Gb of RAM.
I'm using Postgresql 8.1 on ubuntu.
I've indexes on l_pc, r_pc, l_struc,r_struc and prenm (all btrees)
What I'm doing wrong to have such a slow query?
Thanks,
Nuno Mariz
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Optimize slow query
@ 2007-06-13 11:47 Cédric Villemain <cedric.villemain@dalibo.com>
parent: Tyler Durden <tylersticky@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Cédric Villemain @ 2007-06-13 11:47 UTC (permalink / raw)
To: pgsql-performance; +Cc: Tyler Durden <tylersticky@gmail.com>
Le mercredi 13 juin 2007, Tyler Durden a écrit :
> Hi,
> I've a table with 300 000 records and I'm trying to do a search:
>
> SELECT * FROM addresses WHERE address ILIKE '%Jean Paul%' AND
> (l_pc='4250' or r_pc='4250') AND (l_struc='O' or r_struc='O') AND
> (prenm ILIKE 'Street')
>
> It performs in 2 seconds in a dual Xeon 2.4mhz with 2Gb of RAM.
> I'm using Postgresql 8.1 on ubuntu.
> I've indexes on l_pc, r_pc, l_struc,r_struc and prenm (all btrees)
> What I'm doing wrong to have such a slow query?
Could you add 'explain analyze' to your post ?
And how much content have the text fields ? (isn't tsearch2 an option for
you ?)
>
> Thanks,
> Nuno Mariz
>
> ---------------------------(end of broadcast)---------------------------
> TIP 7: You can help support the PostgreSQL project by donating at
>
> http://www.postgresql.org/about/donate
--
Cédric Villemain
Administrateur de Base de Données
Cel: +33 (0)6 74 15 56 53
http://dalibo.com - http://dalibo.org
Attachments:
signature.asc (application/pgp-signature, 188B) download
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Optimize slow query
@ 2007-06-13 11:49 Tyler Durden <tylersticky@gmail.com>
parent: Tyler Durden <tylersticky@gmail.com>
1 sibling, 0 replies; 3+ messages in thread
From: Tyler Durden @ 2007-06-13 11:49 UTC (permalink / raw)
To: pgsql-performance
On 6/13/07, Tyler Durden <tylersticky@gmail.com> wrote:
> Hi,
> I've a table with 300 000 records and I'm trying to do a search:
>
> SELECT * FROM addresses WHERE address ILIKE '%Jean Paul%' AND
> (l_pc='4250' or r_pc='4250') AND (l_struc='O' or r_struc='O') AND
> (prenm ILIKE 'Street')
>
> It performs in 2 seconds in a dual Xeon 2.4mhz with 2Gb of RAM.
> I'm using Postgresql 8.1 on ubuntu.
> I've indexes on l_pc, r_pc, l_struc,r_struc and prenm (all btrees)
> What I'm doing wrong to have such a slow query?
>
> Thanks,
> Nuno Mariz
>
My bad!
Sorry, I've missed an index on l_struc and r_struc.
Thanks, anyway.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2007-06-13 11:49 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-06-13 11:41 Optimize slow query Tyler Durden <tylersticky@gmail.com>
2007-06-13 11:47 ` Cédric Villemain <cedric.villemain@dalibo.com>
2007-06-13 11:49 ` Tyler Durden <tylersticky@gmail.com>
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