Re: R-tree, order by, limit

From: "Anton Belyaev" <anton(dot)belyaev(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: R-tree, order by, limit
Date: 2008-09-21 14:20:27
Message-ID: d7e834b0809210720gda8da12ub1d4f23ef7eadb16@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

2008/9/21 Anton Belyaev <anton(dot)belyaev(at)gmail(dot)com>:
> Hello,
>
> I am implementing a map application. There are towns with altitude,
> longitude and population.
> One of the tasks is to be able to query N biggest (by population)
> towns within a rectangle.
>
> Something like (maybe the syntax in not quite right, but the idea is obvious):
> SELECT * FROM towns where alt1 <= alt <= alt2 AND long1 <= long <=
> long2 ORDER BY population LIMIT 10;
>
> If I create an R-tree index on coordinates (alt, long) this will speed
> up the query significantly. But it is still far from optimal: Despite
> we need only 10 biggest towns, all towns in the rectangle specified
> will be examined.
>
> What if we include population into R-tree index? This index will
> handle a 3D space with coordinates (alt, long, population).
> Will this 3D index perform better than that 2D index?
>
> In fact, I lack some details on how Postges handles ORDER_BY and LIMIT
> inside R-tree indexes.
> Extensive answers and links are appreciated.
>
> Thanks.
> Anton.
>

Sorry, I meant latitude (lat) instead of altitude (alt).

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Kevin Hunter 2008-09-21 14:29:03 Re: PDF Documentation for 8.3?
Previous Message Anton Belyaev 2008-09-21 14:17:39 Re: R-tree, order by, limit