Re: Slow query with a lot of data

From: Moritz Onken <onken(at)houseofdesign(dot)de>
To:
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: Slow query with a lot of data
Date: 2008-08-18 15:49:38
Message-ID: 0BFF9855-F1FA-4A83-B8B2-622D7CE69F77@houseofdesign.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

>>
>
> Well, you're getting the database to read the entire contents of the
> domain_categories table in order. That's 12 million rows - a fair
> amount of work.
>
> You may find that removing the "user = 1337" constraint doesn't make
> the query much slower - that's where you get a big win by clustering
> on domain. You might also want to cluster the results table on domain.

Running the query for more than one user is indeed not much slower.
That's what I need. I'm clustering the results table on domain right
now. But why is this better than clustering it on "user"?

>
>
> If you want the results for just one user, it would be very helpful
> to have a user column on the domain_categories table, and an index
> on that column. However, that will slow down the query for all users
> a little.

A row in domain_categories can belong to more than one user. But I
don't need to run this query for only one user anyway.

Thanks so far,

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matthew Wakeling 2008-08-18 16:05:11 Re: Slow query with a lot of data
Previous Message Mark Wong 2008-08-18 15:33:44 Re: file system and raid performance