Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 6EDDE215DC2 for ; Mon, 23 Jan 2012 13:27:05 -0400 (AST) Received: from mail-yw0-f46.google.com ([209.85.213.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RpNfb-000704-MG for pgsql-performance@postgresql.org; Mon, 23 Jan 2012 17:27:05 +0000 Received: by yhoo21 with SMTP id o21so1358175yho.19 for ; Mon, 23 Jan 2012 09:26:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; bh=m465e/DF9tjLU2dr3wMcZv5OoK49wVkNL6idKLiFmbA=; b=Ljdw9FMMLt+0gd1kVznvbCwyWjkMKYcuJuefVoa5W44YNqdqDDlQ+5pjgUn8jxTguW vuHsIJ6MU3iOF0OU0wdqPzqUwBH3WerD0zyOeDjyKI9WR2HqGicVZDtaz/4xhgTYFiUq YBbW/cKMUTxgP1lx1uYq1k6x++r1l6hpt0eLs= Received: by 10.236.115.231 with SMTP id e67mr12588956yhh.16.1327339610714; Mon, 23 Jan 2012 09:26:50 -0800 (PST) Received: from [192.168.1.50] ([177.35.194.89]) by mx.google.com with ESMTPS id y58sm22217494yhi.17.2012.01.23.09.26.48 (version=SSLv3 cipher=OTHER); Mon, 23 Jan 2012 09:26:49 -0800 (PST) Message-ID: <4F1D9857.90707@gmail.com> Date: Mon, 23 Jan 2012 15:26:47 -0200 From: alexandre - aldeia digital User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: Discovering the most searched values for a field References: <4F10733B.3000704@gmail.com> <4F108122.3040400@agliodbs.com> In-Reply-To: <4F108122.3040400@agliodbs.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201201/56 X-Sequence-Number: 46069 Em 13-01-2012 17:08, Josh Berkus escreveu: > 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. > Thanks Josh ! I will try this. The only problem is the size of the LOGs. One day with logs turned on generates 100 GB log file in the most of my customers...