X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3F5BFD1E872 for ; Fri, 23 Jan 2004 00:21:00 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 14720-02 for ; Thu, 22 Jan 2004 20:20:32 -0400 (AST) Received: from smtp.istop.com (dci.doncaster.on.ca [66.11.168.194]) by svr1.postgresql.org (Postfix) with ESMTP id CEC5CD1E888 for ; Thu, 22 Jan 2004 20:20:28 -0400 (AST) Received: from stark.xeocode.com (gsstark.mtl.istop.com [66.11.160.162]) by smtp.istop.com (Postfix) with ESMTP id 48ACA36B10; Thu, 22 Jan 2004 19:20:26 -0500 (EST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1Ajp3i-0008T1-00; Thu, 22 Jan 2004 19:20:26 -0500 To: "Shea,Dan [CIS]" Cc: pgsql-performance@postgresql.org Subject: Re: database performance and query performance question References: In-Reply-To: From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 22 Jan 2004 19:20:25 -0500 Message-ID: <874qunzfau.fsf@stark.xeocode.com> Lines: 48 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/233 X-Sequence-Number: 5407 "Shea,Dan [CIS]" writes: > Indexes: > "forecastelement_vrwi_idx" btree (valid_time,region_id.wx_element.issue_time) > > explain analyze > SELECT DISTINCT ON (valid_time) > to_char(valid_time,'YYYYMMDDHH24MISS') AS valid_time, > value > from ( > SELECT valid_time,value, "time"(valid_time) AS hour, reception_time, issue_time > FROM forecastelement > WHERE valid_time BETWEEN '2002-09-02 04:00:00' AND '2002-09-07 03:59:59' > AND region_id = 'PU-REG-WTO-00200' > AND wx_element = 'TEMP_VALEUR1' > AND issue_time BETWEEN '2002-09-02 05:00:00' AND '2002-09-06 05:00:00' > AND origin = 'REGIONAL' > AND "time"(issue_time) = '05:00:00' > ORDER BY issue_time,reception_time DESC,valid_time > ) AS foo > WHERE > ( date(valid_time) = date(issue_time)+1 -1 > OR date(valid_time) = date(issue_time)+1 > OR ( valid_time BETWEEN '2002-09-07 00:00:00' AND '2002-09-07 03:59:59' > AND issue_time = '2002-09-06 05:00:00' > ) > ) > ORDER BY valid_time ,issue_time DESC; Incidentally, I find it easier to analyze queries when they've been formatted well. This makes what's going on much clearer.