X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 9C182D1C9DB for ; Fri, 1 Aug 2003 12:20:00 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 37238-10 for ; Fri, 1 Aug 2003 09:18:57 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id BDC68D1C9D8 for ; Fri, 1 Aug 2003 09:19:59 -0300 (ADT) Received: from acdc.int.libertyrms.com ([10.1.2.254] helo=libertyrms.info) by mail.libertyrms.com with smtp (Exim 3.22 #3 (Debian)) id 19iYt8-0004fA-00; Fri, 01 Aug 2003 08:20:02 -0400 Received: from 64.229.210.126 (SquirrelMail authenticated user cbbrowne) by look.libertyrms.com with HTTP; Fri, 1 Aug 2003 08:20:02 -0400 (EDT) Message-ID: <61665.64.229.210.126.1059740402.squirrel@look.libertyrms.com> Date: Fri, 1 Aug 2003 08:20:02 -0400 (EDT) Subject: Re: Views With Unions From: "Christopher Browne" To: In-Reply-To: <20030731152719.V26943-100000@megazone.bigpanda.com> References: <60adaunxmc.fsf@dev6.int.libertyrms.info> <20030731152719.V26943-100000@megazone.bigpanda.com> X-Priority: 3 Importance: Normal Cc: Reply-To: cbbrowne@libertyrms.info X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/3 X-Sequence-Number: 2820 Stephan Szabo said: > > On Thu, 31 Jul 2003, Christopher Browne wrote: > >> select * from log_table where request_time between 'june 11 2003' >> and >> 'june 12 2003'; >> >> returns a plan: >> Subquery Scan log_table (cost=0.00..10950.26 rows=177126 width=314) >> -> Append (cost=0.00..10950.26 rows=177126 width=314) >> -> Subquery Scan *SELECT* 1 (cost=0.00..3089.07 rows=50307 >> width=71) >> -> Seq Scan on log_table_1 (cost=0.00..3089.07 >> rows=50307 width=71) >> -> Subquery Scan *SELECT* 2 (cost=0.00..602.92 rows=9892 >> width=314) >> -> Seq Scan on log_table_2 (cost=0.00..602.92 >> rows=9892 width=314) >> -> Subquery Scan *SELECT* 3 (cost=0.00..2390.09 rows=39209 >> width=314) >> -> Seq Scan on log_table_3 (cost=0.00..2390.09 >> rows=39209 width=314) > > What version are you using? In 7.3 and up it should be willing to > consider moving the clause down, unless there's something like a type > mismatch (because in that case it may not be equivalent without a bunch > more work on the clause). That was 7.2.4, although I had also tried it on 7.4 (yesterday's CVS). Which provides four findings: 1. On 7.2.4, adding additional type info just doesn't help, fitting with the notion that, consistent with your comment, improvement wouldn't happen earlier than 7.3. There's no help on 7.2 :-(, and the system I'm initially most interested in using this on is still on 7.2. 2. When I retried on 7.4, it _did_ find search paths based on Index Scan, when I added in additional type information. So the optimization I was wishing for _is_ there :-). In the longer term, that's very good news. 3. I'll have to test this out on 7.3.4, now, as I hadn't, and it sounds as though that is an interesting case. 4. It's often necessary to expressly specify type information in queries to get the optimizer to do the Right Thing. -- (reverse (concatenate 'string "ofni.smrytrebil@" "enworbbc")) Christopher Browne (416) 646 3304 x124 (land)