Re: Auto-clustering?

From: Royce Ausburn <royce(dot)ml(at)inomial(dot)com>
To: Filip Rembiałkowski <filip(dot)rembialkowski(at)gmail(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Auto-clustering?
Date: 2010-12-18 22:39:38
Message-ID: F7B567EA-4758-4566-92E6-7BEC51D225DE@inomial.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance


On 17/12/2010, at 8:27 PM, Filip Rembiałkowski wrote:

>
> 2010/12/17 Royce Ausburn <royce(at)inomial(dot)com>
> Hi all,
>
> I have a table that in the typical case holds two minute sample data for a few thousand sources. Often we need to report on these data for a particular source over a particular time period and we're finding this query tends to get a bit slow.
>
>
> how about (auto)vacuuming?

A key piece of information I left out: we almost never update rows in this table.

>
>
> I figure at most there should only be ~20,000 rows to be read from disk, and I expect that the index is doing a pretty good job of making sure only the rows that need reading are read. inclusion of the ip in the query is almost redundant as most of the time an ip has its own collection.... My suspicion is that the rows that we're interested in are very sparsely distributed on disk, so we're having to read too many pages for the query...
>
>
> you can test this suspicion in very simple way:
> - create test table (like yours including indexes including constraints, but with no data)
> - insert into test select * from yours order by
> - analyze test tablee available
> - test the query on the new table
>
> If new query is much faster, and if you have intensive random UPD/DEL/INS activity, periodic CLUSTER could be a good idea...
> but it depends on actual usage patterns (SELECT/modify ratio, types of updates, and so on).

Good idea! This vastly improves query times.
>
>
> and finally, you did not specify what PostgreSQL version are you using.

In the case I've been working with it's 8.1 =( But we have a few instances of this database... I believe the rest are a mixture of 8.4s and they all have the same problem.

--Royce

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Royce Ausburn 2010-12-19 03:07:48 Re: Auto-clustering?
Previous Message Ivan Voras 2010-12-18 22:27:07 Re: PostgreSQL 9.0 x64 bit pgbench TPC very low question?