X-Original-To: pgsql-performance@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 738E94763CD for ; Tue, 6 May 2003 09:59:08 -0400 (EDT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id B89C6474E42 for ; Tue, 6 May 2003 09:59:07 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.9/8.12.9) with ESMTP id h46Dx8U6024864; Tue, 6 May 2003 09:59:08 -0400 (EDT) To: Richard Huxton Cc: Reiner Dassing , pgsql-performance@postgresql.org Subject: Re: Select on timestamp-day slower than timestamp alone In-reply-to: <200305061404.24194.dev@archonet.com> References: <3EB75D5F.5080406@wettzell.ifag.de> <200305061404.24194.dev@archonet.com> Comments: In-reply-to Richard Huxton message dated "Tue, 06 May 2003 14:04:24 +0100" Date: Tue, 06 May 2003 09:59:08 -0400 Message-ID: <24863.1052229548@sss.pgh.pa.us> From: Tom Lane X-Spam-Status: No, hits=-32.3 required=5.0 tests=BAYES_00,EMAIL_ATTRIBUTION,IN_REP_TO,QUOTED_EMAIL_TEXT, REFERENCES,REPLY_WITH_QUOTES autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/64 X-Sequence-Number: 1843 Richard Huxton writes: > Well, the "why" is because the number of rows recommended is so big > (rows=10253528) - I'm also puzzled why we get "timestamp without time zone". Because that's what he specified the constant to be. > Does an explicit cast to "with time zone" help? Writing the constant as timestamp with time zone would fix it. Casting after-the-fact would not. The reason: although both "timestamp minus interval" and "timestamptz minus interval" are constant-foldable, timestamp-to-timestamptz conversion is not (because it depends on SET TIMEZONE). So the planner has to fall back to a default selectivity estimate. With real constants it is able to derive a better estimate. regards, tom lane