Re: How to get RTREE performance from GIST index?

From: Alban Hertroys <dalroi(at)solfertje(dot)student(dot)utwente(dot)nl>
To: Clive Page <cgp(at)star(dot)le(dot)ac(dot)uk>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to get RTREE performance from GIST index?
Date: 2009-11-22 12:28:03
Message-ID: 48385EE5-5031-4085-A7AE-FF5CF21098DF@solfertje.student.utwente.nl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 22 Nov 2009, at 13:19, Clive Page wrote:

> On 22/11/2009 12:09, Alban Hertroys wrote:
>> If you expect indexes to work efficiently on temporary tables you should analyse them after filling them to update the planner's statistics on their contents. If you don't you get the default query plan that's often not efficient.
>
> Alban
>
> Thanks - I didn't know that. I'll try removing the TEMPORARY tag.
>
> Is it documented somewhere that I should have seen?

It's not just temporary tables, it goes for all tables in fact. The difference is that with normal tables there is time for autovacuum to pick them up as needing maintenance, whereas temporary tables are usually queried immediately after they're created so that autovacuum is too late.

This specific case for using ANALYSE isn't explicitly documented, it more or less follows from the usage pattern of temporary tables. From the notes on the documentation of the ANALYZE command (http://www.postgresql.org/docs/8.4/interactive/sql-analyze.html):

"In the default PostgreSQL configuration, The Autovacuum Daemon takes care of automatic analyzing of tables when they are first loaded with data, and as they change throughout regular operation. When autovacuum is disabled, it is a good idea to run ANALYZE periodically, or just after making major changes in the contents of a table."

That last line isn't explicit about temporary tables, but the reason for running ANALYZE in both cases is the same.

Alban Hertroys

--
If you can't see the forest for the trees,
cut the trees and you'll see there is no forest.

!DSPAM:737,4b092e5911731012678321!

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alban Hertroys 2009-11-22 12:45:44 Re: How to get RTREE performance from GIST index?
Previous Message Clive Page 2009-11-22 12:24:50 Re: How to get RTREE performance from GIST index?