Re: ANALYZE after CREATE TABLE AS SELECT...

From: David Steele <david(at)pgmasters(dot)net>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Semyon Reyfman <reyfmans(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ANALYZE after CREATE TABLE AS SELECT...
Date: 2015-02-27 01:21:24
Message-ID: 54EFC694.50505@pgmasters.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2/26/15 5:23 PM, Alvaro Herrera wrote:
> Semyon Reyfman wrote:
>
>> When I create a table with "CREATE TABLE name AS SELECT." statement and
>> immediately afterward use this new table in a query does it make sense to
>> run ANALYZE on the table in between? It appears that postgres should be
>> able to collect very detailed statistics while emitting the table but I am
>> not sure if this is done.
>
> It isn't. It also doesn't create any indexes, which you might want to
> do before analyze.

Is it necessary to create indexes before analyzing?

I usually do, just to be safe, but I thought statistics were based
solely on sampling of the heap.

--
- David Steele
david(at)pgmasters(dot)net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-02-27 01:24:52 Re: ANALYZE after CREATE TABLE AS SELECT...
Previous Message David Steele 2015-02-27 01:18:31 Re: ANALYZE after CREATE TABLE AS SELECT...