Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id B4C5C1337EE1 for ; Fri, 17 Sep 2010 19:14:04 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 85010-02 for ; Fri, 17 Sep 2010 22:13:58 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.17.8]) by mail.postgresql.org (Postfix) with ESMTP id C9FB71337EE2 for ; Fri, 17 Sep 2010 19:13:56 -0300 (ADT) Received: from [192.168.1.6] (static-71-179-240-8.bltmmd.fios.verizon.net [71.179.240.8]) by mrelayeu.kundenserver.de (node=mrbap0) with ESMTP (Nemesis) id 0LeBNU-1OV4TV1DEi-00phzr; Sat, 18 Sep 2010 00:13:53 +0200 Message-ID: <4C93E81F.7080905@2ndquadrant.com> Date: Fri, 17 Sep 2010 18:13:51 -0400 From: Greg Smith User-Agent: Thunderbird 2.0.0.24 (X11/20100317) MIME-Version: 1.0 To: badair@epc-instore.com CC: pgsql-admin@postgresql.org Subject: Re: Ingres statdump equivalent for postgresql References: <1284745176.201931386@192.168.2.231> In-Reply-To: <1284745176.201931386@192.168.2.231> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:J/OjbIiraPwqE2tACGSRCjzi44lAvUEDRMCznILvugU aFBKjcrLSb/RdsBRZNtwpEKOnxsfpigaf4GUAjkYmuYJLzedXH SOZsMx6I+s4/JoYDyQ03wNfU9eXUoIuBjz6u4KRSJucd/PWaSB CxKPyHNM1mYg92ZQN9yZJn0fWPwqy4g2Jw74Rpde0CcxaG6GD5 sfHluHO+nw+bHz15m7Ag8kNK4PNr8L8qvkR3tyuA9w= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-10 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201009/108 X-Sequence-Number: 35652 badair@epc-instore.com wrote: > I'm looking for a tool that will enable me to dump the data frequency histograms > for a postgresql table. #!/bin/bash DB="$1" TABLE="$2" psql -d $DB -x -c "SELECT tablename,attname,null_frac,avg_width,n_distinct,correlation,most_common_vals,most_common_freqs,histogram_bounds FROM pg_stats where tablename='$TABLE'" Run that, pass it database then table name, and you'll get the data for each column in that table. That should get you started; refer to http://www.postgresql.org/docs/current/interactive/catalog-pg-statistic.html and to http://www.postgresql.org/docs/current/interactive/planner-stats-details.html for more details. -- Greg Smith, 2ndQuadrant US greg@2ndQuadrant.com Baltimore, MD PostgreSQL Training, Services and Support www.2ndQuadrant.us Author, "PostgreSQL 9.0 High Performance" Pre-ordering at: https://www.packtpub.com/postgresql-9-0-high-performance/book