Re: timestamp with time zone

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alessandro Gagliardi <alessandro(at)path(dot)com>
Cc: Kevin Grittner <Kevin(dot)Grittner(at)wicourts(dot)gov>, pgsql-performance(at)postgresql(dot)org
Subject: Re: timestamp with time zone
Date: 2012-02-10 06:19:52
Message-ID: 7688.1328854792@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Alessandro Gagliardi <alessandro(at)path(dot)com> writes:
> Still slow as mud: http://explain.depesz.com/s/Zfn
> Now I've got indices on created, timezone, created at time zone timezone,
> and (created at time zone timezone)::date. Clearly the problem isn't a lack
> of indices!...except, wait, it's not actually using blocks_created_date_idx
> (or blocks_created_at_timezone_idx). How do I make that happen?

Did you ANALYZE the table after creating those indexes? Generally you
need an ANALYZE so that the planner will have some stats about an
expression index.

It might still think that the other index is a better option. In that
case you can experiment to see if it's right or not; the general idea
is

begin;
drop index index_that_planner_prefers;
explain analyze your_query;
rollback; -- revert the index drop

If that EXPLAIN isn't actually any better than what you had, then the
planner was right. If it is better, let's see 'em both.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Merlin Moncure 2012-02-10 15:19:10 Re: Performance on large, append-only tables
Previous Message Scott Marlowe 2012-02-10 01:29:10 Re: random_page_cost = 2.0 on Heroku Postgres