Skip site navigation (1) Skip section navigation (2)

Re: Explain plan for 2 column index

From: Richard Huxton <dev(at)archonet(dot)com>
To: <lnd(at)hnit(dot)is>, <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Explain plan for 2 column index
Date: 2004-01-29 21:37:16
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
On Thursday 29 January 2004 19:29, lnd(at)hnit(dot)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 
  Richard Huxton
  Archonet Ltd

In response to


pgsql-performance by date

Next:From: Tom LaneDate: 2004-01-29 22:01:05
Subject: Re: query optimization question
Previous:From: Jack CoatesDate: 2004-01-29 21:23:28
Subject: Re: query optimization question

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group