Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGo9e-0007d1-Pw for pgsql-general@arkaria.postgresql.org; Mon, 20 Nov 2017 15:38:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eGo9e-0005vY-9S for pgsql-general@arkaria.postgresql.org; Mon, 20 Nov 2017 15:38:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eGo9e-0005vO-36 for pgsql-general@lists.postgresql.org; Mon, 20 Nov 2017 15:38:38 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eGo9W-0002U8-6A for pgsql-general@postgresql.org; Mon, 20 Nov 2017 15:38:37 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vAKFcICx009875; Mon, 20 Nov 2017 10:38:18 -0500 From: Tom Lane To: Luca Ferrari cc: Justin Pryzby , pgsql-general Subject: Re: [GENERAL] unnest-like pg_stats.most_common_values and pg_stats.most_common_freqs In-reply-to: References: <20171117204150.GD25796@telsasoft.com> Comments: In-reply-to Luca Ferrari message dated "Mon, 20 Nov 2017 09:05:03 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <9873.1511192298.1@sss.pgh.pa.us> Date: Mon, 20 Nov 2017 10:38:18 -0500 Message-ID: <9874.1511192298@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Luca Ferrari 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