From: Richard Huxton <dev@archonet.com>
To: lnd@hnit.is
To: pgsql-performance@postgresql.org
Subject: Re: Explain plan for 2 column index
Date: Thu, 29 Jan 2004 21:37:16 +0000
Message-ID: <200401292137.16750.dev@archonet.com> (raw)
In-Reply-To: <0A5B2E3C3A64CA4AB14F76DBCA76DDA44EF9B4@seifur.hnit.is>
References: <0A5B2E3C3A64CA4AB14F76DBCA76DDA44EF9B4@seifur.hnit.is>
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: dev@archonet.com, lnd@hnit.is
Subject: Re: Explain plan for 2 column index
In-Reply-To: <200401292137.16750.dev@archonet.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox