Re: Allow to specify a index name as ANALYZE parameter

From: Alexander Korotkov <a(dot)korotkov(at)postgrespro(dot)ru>
To: nagata(at)sraoss(dot)co(dot)jp
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Allow to specify a index name as ANALYZE parameter
Date: 2018-07-11 11:26:03
Message-ID: CAPpHfdv6t87rXxVkfdzPFZTrPn_Shhtp=-ZVwHaWwfyTtdM4Kw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

On Wed, Jul 11, 2018 at 12:04 PM Yugo Nagata <nagata(at)sraoss(dot)co(dot)jp> wrote:
> When we specify column names for ANALYZE, only the statistics for those columns
> are collected. Similarly, is it useful if we have a option to specify an index
> for ANALYZE to collect only the statistics for expression in the specified index?
>
> A usecase I suppose is that when a new expression index is created and that
> we need only the statistics for the new index. Although ANALYZE of all the indexes
> is usually fast because ANALYZE uses a random sampling of the table rows, ANALYZE
> on the specific index may be still useful if there are other index whose "statistics
> target" is large and/or whose expression takes time to compute, for example.
>
> Attached is the WIP patch to allow to specify a index name as ANALYZE parameter.
> Any documatation is not yet included. I would appreciate any feedback!

I think this makes sense. Once we can collect statistics individually
for regular columns, we should be able to do the same for indexed
expression. Please, register this patch on the next commitfest.

Regarding current implementation I found message "ANALYZE option must
be specified when a column list is provided" to be confusing.
Perhaps, you've missed some negation in this message, since in fact
you disallow analyze with column list.

However, since multicolumn index may contain multiple expression, I
think we should support specifying columns for ANALYZE index clause.
We could support specifying columns by their numbers in the same way
we did for "ALTER INDEX index ALTER COLUMN colnum SET STATISTICS
number".

------
Alexander Korotkov
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Bapat 2018-07-11 11:28:18 Re: Preferring index-only-scan when the cost is equal
Previous Message Ashutosh Bapat 2018-07-11 11:02:50 Re: Expression errors with "FOR UPDATE" and postgres_fdw with partition wise join enabled.