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

Re: Explain plan for 2 column index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: lnd(at)hnit(dot)is, pgsql-performance(at)postgresql(dot)org
Subject: Re: Explain plan for 2 column index
Date: 2004-01-29 22:07:33
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Richard Huxton <dev(at)archonet(dot)com> writes:
>> 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)

> What types are the columns here? If date_from isn't timestamp with time zone,
> that might be the issue.

It clearly isn't, since we can see a coercion to timestamp with time
zone in the query.  My guess is that the original SQL was
	WHERE ... date_from = current_timestamp
This should be
	WHERE ... date_from = localtimestamp
if timestamp without tz is the intended column datatype.  Of course,
it might just be that date_from was declared as the wrong type (it
really sucks that SQL specifies "timestamp" to default to "without
time zone" ...)

			regards, tom lane

In response to

pgsql-performance by date

Next:From: Jack CoatesDate: 2004-01-29 22:26:56
Subject: Re: query optimization question
Previous:From: Tom LaneDate: 2004-01-29 22:01:05
Subject: Re: query optimization question

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