Re: [GENERAL] R-tree, order by, limit

2008-09-22 Thread Mark Cave-Ayland
Anton Belyaev wrote: Mark, thanks for the suggestion. I examined PostGIS some time ago. It is too complex for my simple task and it gives no advantages for me: Well okay but bear in mind the PostGIS is the de-facto standard for most open source GIS tools. Programs like QGIS et al can visualis

Re: [GENERAL] R-tree, order by, limit

2008-09-22 Thread Volkan YAZICI
On Sun, 21 Sep 2008, "Anton Belyaev" <[EMAIL PROTECTED]> writes: > 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? > Does population worth including into a (3D) point (In order to create > a 3D

Re: [GENERAL] R-tree, order by, limit

2008-09-22 Thread Anton Belyaev
2008/9/22 Mark Cave-Ayland <[EMAIL PROTECTED]>: >>> 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. > Have you considered using PostGIS? (http://post

Re: [GENERAL] R-tree, order by, limit

2008-09-22 Thread Anton Belyaev
2008/9/21 Martijn van Oosterhout <[EMAIL PROTECTED]>: > 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 <@ bo

Re: [GENERAL] R-tree, order by, limit

2008-09-22 Thread Mark Cave-Ayland
Anton Belyaev wrote: 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. Hi Anton, Have you considered using PostGIS? (http://postgis.refractions.net). It imp

Re: [GENERAL] R-tree, order by, limit

2008-09-21 Thread Martijn van Oosterhout
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;

Re: [GENERAL] R-tree, order by, limit

2008-09-21 Thread Anton Belyaev
2008/9/21 Anton Belyaev <[EMAIL PROTECTED]>: > 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

Re: [GENERAL] R-tree, order by, limit

2008-09-21 Thread Anton Belyaev
2008/9/21 Volkan YAZICI <[EMAIL PROTECTED]>: > On Sun, 21 Sep 2008, "Anton Belyaev" <[EMAIL PROTECTED]> writes: >> SELECT * FROM towns where alt1 <= alt <= alt2 AND long1 <= long <= >> long2 ORDER BY population LIMIT 10; > > You're absolutely on the wrong path. Don't try to implement a logic, > tha

Re: [GENERAL] R-tree, order by, limit

2008-09-21 Thread Volkan YAZICI
On Sun, 21 Sep 2008, "Anton Belyaev" <[EMAIL PROTECTED]> writes: > SELECT * FROM towns where alt1 <= alt <= alt2 AND long1 <= long <= > long2 ORDER BY population LIMIT 10; You're absolutely on the wrong path. Don't try to implement a logic, that has been implemented by PostgreSQL in the most possi