pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-performance@postgresql.org
Subject: Re: Discovering the most searched values for a field
Date: Fri, 13 Jan 2012 11:08:18 -0800
Message-ID: <4F108122.3040400@agliodbs.com> (raw)
In-Reply-To: <4F10733B.3000704@gmail.com>
References: <4F10733B.3000704@gmail.com>

On 1/13/12 10:08 AM, alexandre - aldeia digital wrote:
> Hi,
> 
> Is there a simple way (or a tool) to discover the most searched values
> in a field from a table ?
> 
> In the pg_stats, I can see the most common values generated by ANALYZE,
> but I want to know how many queries are using this values. With this
> information and the other statistics, I want to create partial indexes
> or use table partitioning to create some benchmarks to speed up the
> database access.

No simple + fast way.

The way to do this is:

1) log all queries
2) load query log into a database
3) filter to queries which only run against that table
4) analyze queries for values against that column.

For (4), we've had the best luck with generating explain plans in XML
and then digesting the XML to look for filter conditions.  Finding
column matches by regex was a lot less successful.

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



view thread (3+ messages)  latest in thread

Message-ID: <4F108122.3040400@agliodbs.com>
Permalink:  ../4F108122.3040400@agliodbs.com/
Also on:    postgresql.org/message-id/4F108122.3040400@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: Discovering the most searched values for a field
  In-Reply-To: <4F108122.3040400@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox