Re: Select performance variation based on the different combinations of using where lower(), order by, and limit

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Tyler Reese <jukey91(at)gmail(dot)com>
Cc: Kevin Grittner <kgrittn(at)ymail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Select performance variation based on the different combinations of using where lower(), order by, and limit
Date: 2013-08-19 17:03:20
Message-ID: CAMkU=1yKRFykBMLSRPsxbOwcDs9=9B0BwQkF0GSScSext48BEQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Aug 18, 2013 at 4:46 PM, Tyler Reese <jukey91(at)gmail(dot)com> wrote:

> I haven't heard of raising the statistics target, so I'll read up on that.
> A few days ago, all 4 cases were responding equally fast. I had been
> messing around with the postgres settings, and I went and dropped all of the
> indexes and recreated them just to see what would happen. I wouldn't think
> that recreating the indexes would cause case 4 to go slow, but that's the
> symptom I am seeing now. Should I be running analyze on a table after it
> has been reindexed?

PostgreSQL keeps statistics on the table's columns with the table, and
they survive a re-index. But the "column" used by the function-based
index is not a real table column. Those statistics are kept with the
index, not the table, and they do not survive the re-index. So you
should analyze the table in order to reacquire those statistics. Since
the problem is that you no longer had statistics at all for that
"column", there is probably no need to increase the statistics target,
just doing the analyze should get you back in business.

Arguably PostgreSQL's autovacuum logic should be better about dealing
with expression-based indices. But for now, a manual analyze is
needed when a new expression-based index is created, or when an
existing one is re-indexed.

Cheers,

Jeff

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Vick Khera 2013-08-19 17:42:07 Re: please suggest i need to test my upgrade
Previous Message Granthana Biswas 2013-08-19 16:58:09 AccessShareLock on pg_authid