Re: Performance issue with 8.2.3 - "C" application

From: Nis Jørgensen <nis(at)superlativ(dot)dk>
To: pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance issue with 8.2.3 - "C" application
Date: 2007-07-25 06:17:58
Message-ID: f86puu$tua$1@sea.gmane.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Karl Denninger skrev:
> I've got an interesting issue here that I'm running into with 8.2.3
>
> This is an application that has run quite well for a long time, and has
> been operating without significant changes (other than recompilation)
> since back in the early 7.x Postgres days. But now we're seeing a LOT
> more load than we used to with it, and suddenly, we're seeing odd
> performance issues.
>
> It APPEARS that the problem isn't query performance per-se. That is,
> while I can find a few processes here and there in a run state when I
> look with a PS, I don't see them consistently churning.
>
> But.... here's the query that has a habit of taking the most time....
>
> select forum, * from post where toppost = 1 and (replied > (select
> lastview from forumlog where login='theuser' and forum=post.forum and
> number is null)) is not false AND (replied > (select lastview from
> forumlog where login='theuser' and forum=post.forum and
> number=post.number)) is not false order by pinned desc, replied desc offset 0 limit 20

Since I can do little to help you with anything else, here is a little
help from a guy with a hammer. It seems you may be able to convert the
subqueries into a left join. Not sure whether this helps, nor whether I
got some bits of the logic wrong, but something like this might help the
planner find a better plan:

SELECT forum, *
FROM post
LEFT JOIN forumlog
ON post.forum = forumlog.forum
AND forumlog.login = 'theuser'
AND (post.number = forumlog.number OR forumlog.number IS NULL)
AND post.replied <= lastview
WHERE forumlog.forum IS NULL
AND forum.toppost = 1
ORDER BY pinned DESC, replied DESC OFFSET 0 LIMIT 20 ;

Nis

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Gregory Stark 2007-07-25 07:58:40 Re: Performance issue with 8.2.3 - "C" application
Previous Message Karl Denninger 2007-07-25 03:35:41 Re: Performance issue with 8.2.3 - "C" application