X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 5303AD1D1BB for ; Thu, 29 Jan 2004 21:37:50 +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 28712-07 for ; Thu, 29 Jan 2004 17:37:21 -0400 (AST) Received: from anchor-post-30.mail.demon.net (anchor-post-30.mail.demon.net [194.217.242.88]) by svr1.postgresql.org (Postfix) with ESMTP id EFD79D1D137 for ; Thu, 29 Jan 2004 17:37:18 -0400 (AST) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-30.mail.demon.net with esmtp (Exim 3.35 #1) id 1AmJqh-000M2x-0U; Thu, 29 Jan 2004 21:37:20 +0000 Received: by mainbox.archonet.com (Postfix, from userid 529) id 0449616E71; Thu, 29 Jan 2004 21:37:18 +0000 (GMT) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 4086916ABD; Thu, 29 Jan 2004 21:37:17 +0000 (GMT) From: Richard Huxton To: , Subject: Re: Explain plan for 2 column index Date: Thu, 29 Jan 2004 21:37:16 +0000 User-Agent: KMail/1.5 References: <0A5B2E3C3A64CA4AB14F76DBCA76DDA44EF9B4@seifur.hnit.is> In-Reply-To: <0A5B2E3C3A64CA4AB14F76DBCA76DDA44EF9B4@seifur.hnit.is> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200401292137.16750.dev@archonet.com> X-Bogosity: No, tests=bogofilter, spamicity=0.000000, version=0.15.3 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200401/310 X-Sequence-Number: 5484 On Thursday 29 January 2004 19:29, lnd@hnit.is wrote: > I have 2 columns index. > The question is if optimizer can use both columns of an index or not, Should do. > i.e. the plan should read like this: > > Index Cond: > ((name)::text = 'name1'::text) > AND ((date_from)::timestamp with time zone= > ('now'::text)::timestamp(6) with time zone) > > Whilst I am getting index scan on first column and filter on the other: > > Index Scan using testtab_name_date_from on testtab (cost=0.00..2.01 > rows=1 width=18) > Index Cond: ((name)::text = 'name1'::text) > Filter: ((date_from)::timestamp with time zone = > ('now'::text)::timestamp(6)with time zone) > > Could the problem be timestamp column or timestamp with time zones? What types are the columns here? If date_from isn't timestamp with time zone, that might be the issue. Also, I'm not convinced timestamp is the same thing as timestamp(6) - why the different accuracies. Also, note that 'now' is deprecated - now() or CURRENT_TIMESTAMP/DATE/etc are preferred. -- Richard Huxton Archonet Ltd