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 25C5E5281C for ; Fri, 27 May 2005 11:54:53 -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 83574-01 for ; Fri, 27 May 2005 14:54:48 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.206]) by svr1.postgresql.org (Postfix) with ESMTP id 5EAE552866 for ; Fri, 27 May 2005 11:54:47 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 68so1831503wra for ; Fri, 27 May 2005 07:54:52 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=YBmy3eVF7PbZWoCOCjUO3w2telGakS3mpmF/4NPLG7D5ujZQwUHCEoeXXvQwv4PxL5BLA1pyVLE+BrIEjwwvKHdsUiyVt5pppuyDCZa2tnRh8XQColP1DIaRLZwx1PrnO53NaeAACEOyDwKbbR/XsgFoychIL3OMKghAdmT+q8s= Received: by 10.54.8.41 with SMTP id 41mr2575876wrh; Fri, 27 May 2005 07:54:52 -0700 (PDT) Received: by 10.54.2.45 with HTTP; Fri, 27 May 2005 07:54:52 -0700 (PDT) Message-ID: <4a0cafe205052707541373ab8a@mail.gmail.com> Date: Fri, 27 May 2005 09:54:52 -0500 From: Josh Close Reply-To: Josh Close To: POSTGRES-PERFORMANCE Subject: Re: slow queries, possibly disk io In-Reply-To: <14584.1117204158@sss.pgh.pa.us> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <4a0cafe205052613242e0d4d10@mail.gmail.com> <758d5e7f05052614232f6c9164@mail.gmail.com> <4a0cafe205052706043ef8f53f@mail.gmail.com> <4a0cafe205052706042d4e60e5@mail.gmail.com> <14584.1117204158@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.304 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200505/412 X-Sequence-Number: 12576 > I think you really want that seqscan to be an indexscan, instead. > I'm betting this is PG 7.4.something? If so, probably the only > way to make it happen is to simplify the now() expression to a constant: >=20 > SELECT COALESCE( SUM( iNumSent ), 0 ) AS iNumSent > FROM adaption.tblBatchHistory_\' || this_rServerIds.iId || \' > WHERE tStamp > \\\'' || (now() - interval \'5 mins\')::text |= | > \'\\\'\'; The dollar sign thing would be a lot easier. I can't get this to work. I'm using a db manager where I can just use ' instead of \'. How would it look for that? In other words, it doesn't have the "create or replace function as ' --stuff ' language 'plpgsql'" it just has the actual function. Makes things a little easier. I'm getting an error at or near "5". >=20 > because pre-8.0 the planner won't realize that the inequality is > selective enough to favor an indexscan, unless it's comparing to > a simple constant. >=20 > (BTW, 8.0's dollar quoting makes this sort of thing a lot less painful) >=20 > regards, tom lane >=20 --=20 -Josh