From: | David Steele <david(at)pgmasters(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Semyon Reyfman <sreyfman(at)therealauthority(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: ANALYZE after CREATE TABLE AS SELECT... |
Date: | 2015-02-27 01:18:31 |
Message-ID: | 54EFC5E7.9050002@pgmasters.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2/26/15 2:05 PM, Tom Lane wrote:
> "Semyon Reyfman" <sreyfman(at)therealauthority(dot)com> writes:
>> 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 new table in between?
>
> Yes.
Yes. And to be more specific - vacuum cannot see tables that have been
created in a transaction, so you should always analyze tables that you
intend to read in the same transaction where you created them.
Even if you do commit before reading there is a race condition with
vacuum, so it's best to analyze.
Bonus tip: the same is true for any temp tables you might create. More
so, since vacuum will never see them at all.
--
- David Steele
david(at)pgmasters(dot)net
From | Date | Subject | |
---|---|---|---|
Next Message | David Steele | 2015-02-27 01:21:24 | Re: ANALYZE after CREATE TABLE AS SELECT... |
Previous Message | Tim Uckun | 2015-02-26 22:34:02 | Re: Triggers and scalability in high transaction tables. |