Обсуждение: Does VACUUM FULL need ANALYZE ?

Поиск
Список
Период
Сортировка

Does VACUUM FULL need ANALYZE ?

От
"Eoin O'Hehir"
Дата:

Eoin O'Hehir <eoin.ohehir@clavisinsight.com>

8:59 PM (0 minutes ago)
to pgsql-admin-ow.
Hi,

I'd be grateful for some insight into the VACUUM functionality in 9.3. I read through the documentation and searched around a bit but could not find a definitive answer to this.

I'm setting up a weekly DB maintenance job for a 9.3 server.

Part of this will be a VACUUM FULL.

Is there any point in adding the ANALYZE option to the command ?

According to the 9.3 documentation, "VACUUM FULL rewrites the entire contents of the table into a new disk file with no extra space, allowing unused space to be returned to the operating system.". If the table is completely recreated then do I need to specifically ask for ANALYZE to happen or are the statistics updated automatically as the rows are written to the new version of the table ?

Thanks,

Re: Does VACUUM FULL need ANALYZE ?

От
Venkata Balaji N
Дата:

On Sun, Jun 21, 2015 at 6:02 AM, Eoin O'Hehir <eoin.ohehir@clavisinsight.com> wrote:

Eoin O'Hehir <eoin.ohehir@clavisinsight.com>

8:59 PM (0 minutes ago)
to pgsql-admin-ow.
Hi,

I'd be grateful for some insight into the VACUUM functionality in 9.3. I read through the documentation and searched around a bit but could not find a definitive answer to this.

I'm setting up a weekly DB maintenance job for a 9.3 server.

Part of this will be a VACUUM FULL.

Is there any point in adding the ANALYZE option to the command ?

According to the 9.3 documentation, "VACUUM FULL rewrites the entire contents of the table into a new disk file with no extra space, allowing unused space to be returned to the operating system.". If the table is completely recreated then do I need to specifically ask for ANALYZE to happen or are the statistics updated automatically as the rows are written to the new version of the table ?

VACUUM FULL will only remove the bloats and releases the bloated space to the disk. ANALYZE updates the statistics which will make significant difference in the query's cost calculation.

Regards,
Venkata B N

Fujitsu Australia

Re: Does VACUUM FULL need ANALYZE ?

От
Kevin Grittner
Дата:
Eoin O'Hehir <eoin.ohehir@clavisinsight.com> wrote:

> I'm setting up a weekly DB maintenance job for a 9.3 server.
>
> Part of this will be a VACUUM FULL.

That's something to seriously reconsider.

> Is there any point in adding the ANALYZE option to the command ?

That and a non-FULL VACUUM command after VACUUM FULL.  Unlike what
you might expect based on the FULL option, a VACUUM FULL does not
do everything that a non-FULL VACUUM does, and actually drops any
existing visibility map and free space map -- potentially making
subsequent queries against the table slower until a normal VACUUM
(or autovacuum occurs).  I strongly recommend that if you really do
need to use VACUUM FULL, you immediately follow it with VACUUM
ANALYZE.

You might also want to read this:

http://rhaas.blogspot.com/2014/03/vacuum-full-doesnt-mean-vacuum-but.html

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

Re: Does VACUUM FULL need ANALYZE ?

От
Eoin O'Hehir
Дата:
Thanks Kevin. That provides a lot of clarity. Cheers.

On 26/06/15 20:40, Kevin Grittner wrote:
> Eoin O'Hehir <eoin.ohehir@clavisinsight.com> wrote:
>
>> I'm setting up a weekly DB maintenance job for a 9.3 server.
>>
>> Part of this will be a VACUUM FULL.
> That's something to seriously reconsider.
>
>> Is there any point in adding the ANALYZE option to the command ?
> That and a non-FULL VACUUM command after VACUUM FULL.  Unlike what
> you might expect based on the FULL option, a VACUUM FULL does not
> do everything that a non-FULL VACUUM does, and actually drops any
> existing visibility map and free space map -- potentially making
> subsequent queries against the table slower until a normal VACUUM
> (or autovacuum occurs).  I strongly recommend that if you really do
> need to use VACUUM FULL, you immediately follow it with VACUUM
> ANALYZE.
>
> You might also want to read this:
>
> http://rhaas.blogspot.com/2014/03/vacuum-full-doesnt-mean-vacuum-but.html
>
> --
> Kevin Grittner
> EDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company



Re: Does VACUUM FULL need ANALYZE ?

От
Eoin O'Hehir
Дата:
Thanks Venkata.

On 22/06/15 01:30, Venkata Balaji N wrote:

On Sun, Jun 21, 2015 at 6:02 AM, Eoin O'Hehir <eoin.ohehir@clavisinsight.com> wrote:

Eoin O'Hehir <eoin.ohehir@clavisinsight.com>

8:59 PM (0 minutes ago)
to pgsql-admin-ow.
Hi,

I'd be grateful for some insight into the VACUUM functionality in 9.3. I read through the documentation and searched around a bit but could not find a definitive answer to this.

I'm setting up a weekly DB maintenance job for a 9.3 server.

Part of this will be a VACUUM FULL.

Is there any point in adding the ANALYZE option to the command ?

According to the 9.3 documentation, "VACUUM FULL rewrites the entire contents of the table into a new disk file with no extra space, allowing unused space to be returned to the operating system.". If the table is completely recreated then do I need to specifically ask for ANALYZE to happen or are the statistics updated automatically as the rows are written to the new version of the table ?

VACUUM FULL will only remove the bloats and releases the bloated space to the disk. ANALYZE updates the statistics which will make significant difference in the query's cost calculation.

Regards,
Venkata B N

Fujitsu Australia