pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nis Jørgensen <nis@superlativ.dk>
To: pgsql-performance@postgresql.org
Subject: Re: Performance issue with 8.2.3 - "C" application
Date: Wed, 25 Jul 2007 08:17:58 +0200
Message-ID: <f86puu$tua$1@sea.gmane.org> (raw)
In-Reply-To: <46A6A549.1040606@denninger.net>
References: <46A6A549.1040606@denninger.net>

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




view thread (10+ messages)  latest in thread

Message-ID: <f86puu$tua$1@sea.gmane.org>
Permalink:  ../f86puu$tua$1@sea.gmane.org/
Also on:    postgresql.org/message-id/f86puu$tua$1@sea.gmane.org

 · 

reply

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: nis@superlativ.dk
  Subject: Re: Performance issue with 8.2.3 - "C" application
  In-Reply-To: <f86puu$tua$1@sea.gmane.org>

* 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