pgbench -i order of vacuum

Lists: pgsql-hackers
From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: pgbench -i order of vacuum
Date: 2012-07-20 00:05:36
Message-ID: CAMkU=1y8-YpafmvQUChGqp85z+tXanGrMY37AHOcZoxgaW_vNQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Is there a reason to vacuum the pgbench_* tables after the indexes on
them are built, rather than before?

Since the indexes are on fresh tables, they can't have anything that
needs to be cleaned.

I don't think the current order accomplishes anything, except to slow
down large initializations by ~25%.

The attached patch moves the vacuums up.

I also made -n skip the vacuums altogether. Since -n is allowed under
-i, it would be nice if it did something, and there is only one
intuitive thing for it to do. I don't know what the use case for is,
but I think I've heard grumbling about it before.

Cheers,

Jeff

Attachment Content-Type Size
pgbench_vacuum_order_v1.patch application/octet-stream 2.7 KB

From: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
To: "'Jeff Janes'" <jeff(dot)janes(at)gmail(dot)com>, "'pgsql-hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench -i order of vacuum
Date: 2012-07-20 14:57:21
Message-ID: 000d01cd6687$f766f3f0$e634dbd0$@kapila@huawei.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> From: pgsql-hackers-owner(at)postgresql(dot)org
[mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Jeff Janes
> Sent: Friday, July 20, 2012 5:36 AM

> Is there a reason to vacuum the pgbench_* tables after the indexes on them
are built, rather than before?

> Since the indexes are on fresh tables, they can't have anything that needs
to be cleaned.

The command it executes is "vacuum analyze ..", so it will do analyze also
on table which means
it will collect stats corresponding to table and index. So if you do it
before creation of index pgbench might behave
different.
In specific, from function do_analyze_rel(), it will not call
compute_index_stats() if you execute the command before
Creation of index.

With Regards,
Amit Kapila.


From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench -i order of vacuum
Date: 2012-07-20 15:37:08
Message-ID: CAMkU=1xqhCpBeBXjO3oEnh4q4emDSZVc6hrLyzMcHQ6Y15-6Fw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jul 20, 2012 at 7:57 AM, Amit Kapila <amit(dot)kapila(at)huawei(dot)com> wrote:
>> From: pgsql-hackers-owner(at)postgresql(dot)org
> [mailto:pgsql-hackers-owner(at)postgresql(dot)org] On Behalf Of Jeff Janes
>> Sent: Friday, July 20, 2012 5:36 AM
>
>
>> Is there a reason to vacuum the pgbench_* tables after the indexes on them
> are built, rather than before?
>
>> Since the indexes are on fresh tables, they can't have anything that needs
> to be cleaned.
>
> The command it executes is "vacuum analyze ..", so it will do analyze also
> on table which means
> it will collect stats corresponding to table and index.

Are there stats collected on indexes? I thought all stats were on
tables only, and the only reason to visit the index was to remove
all-visible-dead entries.

Cheers,

Jeff


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench -i order of vacuum
Date: 2012-07-20 16:26:44
Message-ID: 24263.1342801604@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:
> On Fri, Jul 20, 2012 at 7:57 AM, Amit Kapila <amit(dot)kapila(at)huawei(dot)com> wrote:
>> The command it executes is "vacuum analyze ..", so it will do analyze also
>> on table which means
>> it will collect stats corresponding to table and index.

> Are there stats collected on indexes?

Only for expression indexes, which there aren't any of in the standard
pgbench scenario. I don't see a reason not to change the ordering
as you suggest.

regards, tom lane


From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pgbench -i order of vacuum
Date: 2012-07-23 18:45:01
Message-ID: CA+TgmoY9vva2xiRtC4ovpjQ8DNiyCaZOGd9rtH-dGHG6n5vrhw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Fri, Jul 20, 2012 at 12:26 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Jeff Janes <jeff(dot)janes(at)gmail(dot)com> writes:
>> On Fri, Jul 20, 2012 at 7:57 AM, Amit Kapila <amit(dot)kapila(at)huawei(dot)com> wrote:
>>> The command it executes is "vacuum analyze ..", so it will do analyze also
>>> on table which means
>>> it will collect stats corresponding to table and index.
>
>> Are there stats collected on indexes?
>
> Only for expression indexes, which there aren't any of in the standard
> pgbench scenario. I don't see a reason not to change the ordering
> as you suggest.

OK, done.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company