From: | "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de> |
---|---|
To: | "Claudio Freire" <klaussfreire(at)gmail(dot)com>, "Mark" <Marek(dot)Balgar(at)seznam(dot)cz> |
Cc: | <pgsql-performance(at)postgresql(dot)org> |
Subject: | Re: Query improvement |
Date: | 2011-05-03 09:14:01 |
Message-ID: | C4DAC901169B624F933534A26ED7DF310861AE8B@JENMAIL01.ad.intershop.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
> On Mon, May 2, 2011 at 10:54 PM, Mark <Marek(dot)Balgar(at)seznam(dot)cz> wrote:
> > but the result have been worst than before. By the way is there a
posibility
> > to create beeter query with same effect?
> > I have tried more queries, but this has got best performance yet.
>
> Well, this seems to be the worst part:
>
> (SELECT page_id FROM mediawiki.page WHERE page_id IN
> (SELECT page_id FROM mediawiki.page
> WHERE (titlevector @@ (to_tsquery('fotbal'))))
> OR page_id IN
> (SELECT p.page_id from mediawiki.page
p,mediawiki.revision r,
> (SELECT old_id FROM mediawiki.pagecontent
> WHERE (textvector @@ (to_tsquery('fotbal')))) ss
> WHERE (p.page_id=r.rev_page AND r.rev_id=ss.old_id)))
>
'OR' statements often generate complicated plans. You should try to
rewrite your Query with a n UNION clause.
Using explicit joins may also help the planner:
SELECT page_id
FROM mediawiki.page
WHERE (titlevector @@ (to_tsquery('fotbal')))
UNION
SELECT p.page_id
FROM mediawiki.page p
JOIN mediawiki.revision r on (p.page_id=r.rev_page)
JOIN mediawiki.pagecontent ss on (r.rev_id=ss.old_id)
WHERE (ss.textvector @@ (to_tsquery('fotbal')))
HTH,
Marc Mamin
From | Date | Subject | |
---|---|---|---|
Next Message | Willy-Bas Loos | 2011-05-03 15:52:23 | [PERFORMANCE] expanding to SAN: which portion best to move |
Previous Message | Sethu Prasad | 2011-05-03 09:02:59 | Postgres 9.0.4 + Hot Standby + FusionIO Drive + Performance => Query failed ERROR: catalog is missing 1 attribute(s) for relid 172226 |