X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5358A14B281F for ; Wed, 11 Aug 2004 20:53:35 -0300 (ADT) 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 28089-01 for ; Wed, 11 Aug 2004 23:53:34 +0000 (GMT) Received: from mail.pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id 16C7C14B2824 for ; Wed, 11 Aug 2004 20:53:32 -0300 (ADT) Received: (qmail 2818 invoked by uid 0); 12 Aug 2004 09:53:35 +1000 Received: from cpe-203-45-44-212.vic.bigpond.net.au (HELO wizzard.pws.com.au) (russell@pws.com.au@203.45.44.212) by mail.pws.com.au with SMTP; 12 Aug 2004 09:53:35 +1000 From: Russell Smith To: pgsql-performance@postgresql.org Subject: Re: Hardware upgrade for a high-traffic database Date: Thu, 12 Aug 2004 09:52:20 +1000 User-Agent: KMail/1.6.1 References: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> In-Reply-To: <200408111908.i7BJ8m0E094620@mail.gotfrag.com> MIME-Version: 1.0 Content-Disposition: inline Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <200408120952.20352.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200408/176 X-Sequence-Number: 7812 [snip] > > One question I do have though - you specifically mentioned NOW() as > something to watch out for, in that it's mutable. We typically use COUNT() > as a subselect to retrieve the number of associated rows to the current > query. Additionally, we use NOW a lot, primarily to detect the status of a > date, i.e.: > > SELECT id FROM subscriptions WHERE userid = 11111 AND timeend > NOW(); > > Is there a better way to do this? I was under the impression that NOW() was > pretty harmless, just to return a current timestamp. > NOW() will trigger unnessecary sequence scans. As it is unknown with prepared query and function when the statement is run, the planner plans the query with now as a variable. This can push the planner to a seq scan over and index scan. I have seen this time and time again. You can create your own immutable now, but don't use it in functions or prepared queries or you will get wrong results. > Based on feedback, I'm looking at a minor upgrade of our RAID controller to > a 3ware 9000 series (SATA with cache, battery backup optional), and > re-configuring it for RAID 10. It's a damn cheap upgrade at around $350 and > an hour of downtime, so I figure that it's worth it for us to give it a > shot. > > Thanks, > > Jason Russell Smith