Re: vacuumdb --all --analyze-in-stages - wrong order?

Lists: pgsql-hackers
From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-05-18 07:52:49
Message-ID: CAFj8pRB-Ay_uC2oMdzR8p_jJoOi-Rbr1a8k9YMLRz6dY-QGnnA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello

I am looking on --analyze-in-stages option. If I understand well,
motivation for this option is a get some minimal statistic for databases in
minimal time. But when I tested, I found so iterations are per databases,
not per stages - some first database get a maximum statistics and second
has zero statistics. Isn't it unpractical?

Now:

DB a
stage 1, stage2, stage3
DB b
stage 1, stage2, stage3

should be:

Stage1
DB a, DB b ...
Stage 2
DB a, DB b ...
Stage 3
DB a, DB b, ..

Regards

Pavel


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-05-19 17:51:27
Message-ID: 537A449F.1020108@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 5/18/14, 3:52 AM, Pavel Stehule wrote:
> Hello
>
> I am looking on --analyze-in-stages option. If I understand well,
> motivation for this option is a get some minimal statistic for databases
> in minimal time. But when I tested, I found so iterations are per
> databases, not per stages - some first database get a maximum statistics
> and second has zero statistics. Isn't it unpractical?

Yes. Let me see if I can fix that.


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-09-04 03:36:01
Message-ID: 1409801761.427.1.camel@vanquo.pezone.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Mon, 2014-05-19 at 13:51 -0400, Peter Eisentraut wrote:
> On 5/18/14, 3:52 AM, Pavel Stehule wrote:
> > I am looking on --analyze-in-stages option. If I understand well,
> > motivation for this option is a get some minimal statistic for databases
> > in minimal time. But when I tested, I found so iterations are per
> > databases, not per stages - some first database get a maximum statistics
> > and second has zero statistics. Isn't it unpractical?
>
> Yes. Let me see if I can fix that.

At long last, here is a patch.

If somebody has an idea how to code some of that less confusingly, let
me know.

Attachment Content-Type Size
fix-analyze-in-stages.patch text/x-patch 4.7 KB

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-09-04 20:23:48
Message-ID: CAFj8pRC6uMeNOik3tTgHcwt+ToAcUUCPkqAfj+=L5QRzufgkqw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-09-04 5:36 GMT+02:00 Peter Eisentraut <peter_e(at)gmx(dot)net>:

> On Mon, 2014-05-19 at 13:51 -0400, Peter Eisentraut wrote:
> > On 5/18/14, 3:52 AM, Pavel Stehule wrote:
> > > I am looking on --analyze-in-stages option. If I understand well,
> > > motivation for this option is a get some minimal statistic for
> databases
> > > in minimal time. But when I tested, I found so iterations are per
> > > databases, not per stages - some first database get a maximum
> statistics
> > > and second has zero statistics. Isn't it unpractical?
> >
> > Yes. Let me see if I can fix that.
>
> At long last, here is a patch.
>
> If somebody has an idea how to code some of that less confusingly, let
> me know.
>
> It is little bit hard to read.

/* If stage is -1, then run all stages. Otherwise, we got
a stage
* from vacuum_all_databases(), so just run that one. */
for (i = (stage == -1 ? 0 : stage); i < (stage == -1 ? 3 :
stage + 1); i++)
{
puts(gettext(stage_messages[i]));
executeCommand(conn, stage_commands[i], progname,
echo);
run_vacuum_command(conn, sql.data, echo, dbname,
table, progname);
}

maybe better be more verbose - and it can be in alone function, because it
is "analyze only"

if (stage == -1)
{
for (i = 0; i < 3; i++)
{
puts(gettext(stage_messages[i]));
executeCommand(conn, stage_commands[i], progname, echo);
run_vacuum_command(conn, sql.data, echo, dbname, table, progname);
}
}
else
{
puts(gettext(stage_messages[stage]));
executeCommand(conn, stage_commands[stage], progname, echo);
run_vacuum_command(conn, sql.data, echo, dbname, table, progname);
}

Regards

Pavel


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-09-12 01:44:39
Message-ID: 54125007.1030509@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 9/4/14 4:23 PM, Pavel Stehule wrote:
> It is little bit hard to read.

> maybe better be more verbose - and it can be in alone function, because
> it is "analyze only"
>
> if (stage == -1)
> {
> for (i = 0; i < 3; i++)
> {
> puts(gettext(stage_messages[i]));
> executeCommand(conn, stage_commands[i], progname, echo);
> run_vacuum_command(conn, sql.data, echo, dbname, table, progname);
> }
> }
> else
> {
> puts(gettext(stage_messages[stage]));
> executeCommand(conn, stage_commands[stage], progname, echo);
> run_vacuum_command(conn, sql.data, echo, dbname, table, progname);
> }

Done that way, thanks!


From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: vacuumdb --all --analyze-in-stages - wrong order?
Date: 2014-09-12 04:26:29
Message-ID: CAFj8pRAbeHjiDYCaouVqL7KXhXu6d11zYtbZkrYQJpC6uFBx_Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

2014-09-12 3:44 GMT+02:00 Peter Eisentraut <peter_e(at)gmx(dot)net>:

> On 9/4/14 4:23 PM, Pavel Stehule wrote:
> > It is little bit hard to read.
>
> > maybe better be more verbose - and it can be in alone function, because
> > it is "analyze only"
> >
> > if (stage == -1)
> > {
> > for (i = 0; i < 3; i++)
> > {
> > puts(gettext(stage_messages[i]));
> > executeCommand(conn, stage_commands[i], progname, echo);
> > run_vacuum_command(conn, sql.data, echo, dbname, table,
> progname);
> > }
> > }
> > else
> > {
> > puts(gettext(stage_messages[stage]));
> > executeCommand(conn, stage_commands[stage], progname, echo);
> > run_vacuum_command(conn, sql.data, echo, dbname, table, progname);
> > }
>
> Done that way, thanks!
>

Thank you

It is interesting feature

Pavel