Re: [GENERAL] unnest-like pg_stats.most_common_values and pg_stats.most_common_freqs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Luca Ferrari <fluca1978(at)infinito(dot)it>
Cc: Justin Pryzby <pryzby(at)telsasoft(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] unnest-like pg_stats.most_common_values and pg_stats.most_common_freqs
Date: 2017-11-20 15:38:18
Message-ID: 9874.1511192298@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Luca Ferrari <fluca1978(at)infinito(dot)it> writes:
> I don't think it is what I'm looking for, I would like something ,like:
> select unnest( histogram_bounds::text::text[] ), unnest(
> most_common_freqs ) from pg_stats
> but with correlation between the two array indexes. Is it something
> achievable in SQL? Or should I use a plpgsql loop with an index?

Those two aren't correlated ... but I think what you want is

select ...,v,f
from
pg_stats,
rows from (unnest(most_common_vals::text::text[]),
unnest(most_common_freqs)) r(v,f)
where ...

Seems to work back to 9.4.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2017-11-20 17:32:26 Re: Migration to PGLister - After
Previous Message Stephen Frost 2017-11-20 15:34:02 Re: [ADMIN] Migration to pglister - Before