Re: R-tree, order by, limit - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: R-tree, order by, limit
Date
Msg-id 20080921150958.GF4361@svana.org
Whole thread Raw
In response to Re: R-tree, order by, limit  ("Anton Belyaev" <anton.belyaev@gmail.com>)
Responses Re: R-tree, order by, limit
List pgsql-general
On Sun, Sep 21, 2008 at 06:17:39PM +0400, Anton Belyaev wrote:
> Geometry types and functions use R-tree indexes anyways.
>
> I can rephrase the query using geometry language of Postgres:
> SELECT * FROM towns WHERE towns.coordinates <@ box(alt1, long1, alt2,
> long2) ORDER BY population LIMIT 10;
>
> And the questions about population remain the same:
> How to avoid examination of all the towns in the rectangle knowing
> that we need only 10 biggest?

I don't know if it solves your problem, but you should be able to do a
multi-column GiST index with both the position data and the population
data in it. However, I'm unsure if postgresql will correctly use the
index to solve the order by...

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Attachment

pgsql-general by date:

Previous
From: Kevin Hunter
Date:
Subject: Re: PDF Documentation for 8.3?
Next
From: "Dean Grubb"
Date:
Subject: PL/Python - Execute return results