Re: ORDER BY ... LIMIT and JOIN

From: Michael Andreen <harv(at)ruin(dot)nu>
To: pgsql-performance(at)postgresql(dot)org
Cc: Fizu <Fizu(at)advancedsl(dot)com(dot)ar>
Subject: Re: ORDER BY ... LIMIT and JOIN
Date: 2009-08-09 23:03:57
Message-ID: 200908100103.58997.harv@ruin.nu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Sunday 09 August 2009 21:26:08 Fizu wrote:
> -> Index Scan using country_ranking_user_idx on "user"
> (cost=0.00..4807.25 rows=1710 width=143) (actual
> time=20.923..4898.931 rows=1972 loops=1)
> Index Cond: (country_id = 5)

The statistics looks good now, but almost all the time is still spent on
fetching users with country_id = 5. The actual ordering is only a tiny part of
the full cost. Why it takes time probably depends on your hardware in relation
to database size. I guess the database doesn't fit in ram? What settings have
you changed?

Clustering users on country_ranking_user_idx would probably help for this
specific case, but if it is a good idea depends on what other queries need to
be fast. If the table or indexes are bloated then clustering on any index or
doing reindex might do it.

/Michael

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Robert Haas 2009-08-10 01:30:38 Re: ORDER BY ... LIMIT and JOIN
Previous Message Fizu 2009-08-09 19:26:08 Re: ORDER BY ... LIMIT and JOIN