pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Michael Paesold <mpaesold@gmx.at>
Cc: Shane|SkinnyCorp <shanew@skinnycorp.com>
Cc: PgSQL ADMIN <pgsql-admin@postgresql.org>
Subject: Re: PLEASE GOD HELP US!
Date: Fri, 1 Oct 2004 14:42:58 -0700 (PDT)
Message-ID: <20041001144100.E67126@megazone.bigpanda.com> (raw)
In-Reply-To: <045401c4a7fc$c9433a80$ad01a8c0@zaphod>
References: <00ab01c4a7f4$f04fffd0$3402a8c0@shanepc>
	<045401c4a7fc$c9433a80$ad01a8c0@zaphod>


On Fri, 1 Oct 2004, Michael Paesold wrote:

> Shane | SkinnyCorp wrote:
>
> > Okay, just so no one posts about this again...
> >
> > the 'ORDER BY t.status=5,lastreply' clause is meant to float the threads
> > with a status of '5' to the top of the list... it is NOT meant to only
> > grab
> > threads where the status = 5.  Oh and believe me, when I take this out of
> > the query, it CERTAINLY doesn't add any more than possible 1/4 of a
> > millesecond to the speed of the SELECT statement.
> >
> > :/
>
> Perhaps I missed it, but you did not yet send the output of the explain of
> this query, did you?
>
> Could you please do:
>
> EXPLAIN SELECT * FROM thread_listing AS t ORDER BY t.status=5 DESC,
> t.lastreply DESC LIMIT 25 OFFSET 0;
>
> EXPLAIN SELECT * FROM thread_listing AS t WHERE t.status=5 ORDER BY
> t.lastreply DESC LIMIT 25 OFFSET 0;
>
> EXPLAIN SELECT * FROM thread_listing AS t ORDER BY t.lastreply DESC LIMIT 25
> OFFSET 0;
>
> (and post the results here)
>
> The first one will certainly do a sequential scan, the last one will use an
> index if available. For the second you will need a partial index on
> lastreply with a where clause WHERE status=5, I believe. So a solution would

Actually, I think he'd want an expression index on ((status=5),lastreply).
In simple tests (admittedly on 8.0b3) it looks like such an index can be
used rather than a separate sort step.



view thread (33+ messages)  latest in thread

Message-ID: <20041001144100.E67126@megazone.bigpanda.com>
Permalink:  ../20041001144100.E67126@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20041001144100.E67126@megazone.bigpanda.com

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-admin@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, mpaesold@gmx.at, shanew@skinnycorp.com
  Subject: Re: PLEASE GOD HELP US!
  In-Reply-To: <20041001144100.E67126@megazone.bigpanda.com>
  References: <00ab01c4a7f4$f04fffd0$3402a8c0@shanepc> <045401c4a7fc$c9433a80$ad01a8c0@zaphod> <20041001144100.E67126@megazone.bigpanda.com>

* 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