X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 7A7CE329E53 for ; Sat, 2 Oct 2004 22:09:04 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 75517-05 for ; Sat, 2 Oct 2004 21:08:58 +0000 (GMT) Received: from mpls-qmqp-01.inet.qwest.net (mpls-qmqp-01.inet.qwest.net [63.231.195.112]) by svr1.postgresql.org (Postfix) with SMTP id AB977329E5D for ; Sat, 2 Oct 2004 22:08:57 +0100 (BST) Received: (qmail 13236 invoked by uid 0); 2 Oct 2004 21:08:55 -0000 Received: from unknown (63.231.195.13) by mpls-qmqp-01.inet.qwest.net with QMQP; 2 Oct 2004 21:08:55 -0000 Received: from 63-227-127-37.dnvr.qwest.net (HELO ?10.0.0.2?) (63.227.127.37) by mpls-pop-13.inet.qwest.net with SMTP; 2 Oct 2004 21:08:55 -0000 Date: Sat, 02 Oct 2004 15:10:54 -0600 Message-Id: <1096751454.2611.33.camel@localhost.localdomain> From: "Scott Marlowe" To: "Stephan Szabo" Cc: "Shane|SkinnyCorp" , "PgSQL ADMIN" Subject: Re: PLEASE GOD HELP US! In-Reply-To: <20041002080923.C99145@megazone.bigpanda.com> References: <00ab01c4a7f4$f04fffd0$3402a8c0@shanepc> <1096691616.2611.22.camel@localhost.localdomain> <20041002080923.C99145@megazone.bigpanda.com> Content-Type: text/plain Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200410/51 X-Sequence-Number: 15044 On Sat, 2004-10-02 at 09:14, Stephan Szabo wrote: > On Fri, 1 Oct 2004, Scott Marlowe wrote: > > > On Fri, 2004-10-01 at 14:26, 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. > > > > > > Wouldn't this work just as well? > > > > SELECT * FROM thread_listing AS t ORDER BY t.status > > DESC,t.lastreply desc LIMIT 25 OFFSET 0 > > Probably not, because I don't think he wants the other statuses to have > special ranking over the others, so a status=4 and status=1 row should be > sorted by lastreply only effectively. This is the problem of combining > separate status flags into a single field if you want to be doing these > sorts of queries. > So would a union give good performance? Just union the first 25 or less with status=5 with the rest, using a 1 and 0 in each union to order by first? Hopefully the indexes would then be used.