Re: cube operations slower than geo_distance() on production server

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: cube operations slower than geo_distance() on production server
Дата
Msg-id b42b73150702130615t22776654u9e0925e0fe368bc1@mail.gmail.com
обсуждение исходный текст
Ответ на Re: cube operations slower than geo_distance() on production server  (Mark Stosberg <mark@summersault.com>)
Ответы Re: cube operations slower than geo_distance() on production server
Список pgsql-performance
On 2/12/07, Mark Stosberg <mark@summersault.com> wrote:
> Merlin Moncure wrote:
> >
> >> Here the basic query I'm using:
> >> SELECT
> >>  -- 1609.344 is a constant for "meters per mile"
> >>  cube_distance( (SELECT earth_coords from zipcodes WHERE zipcode =
> >> '90210') , earth_coords)/1609.344
> >>    AS RADIUS
> >>    FROM pets
> >>    -- "shelters_active" is a view where "shelter_state = 'active'"
> >>    JOIN shelters_active as shelters USING (shelter_id)
> >>    -- The zipcode fields here are varchars
> >>    JOIN zipcodes ON (
> >>         shelters.postal_code_for_joining = zipcodes.zipcode )
> >>    -- search for just 'dogs'
> >>    WHERE species_id = 1
> >>        AND pet_state='available'
> >>       AND earth_box(
> >>         (SELECT earth_coords from zipcodes WHERE zipcode = '90210') ,
> >> 10*1609.344
> >>       ) @ earth_coords
> >>    ORDER BY RADIUS;
> >
> It may not have been clear from the query, but only the 'zipcodes' table
> has an 'earth_coords' column. Also, I think your refactoring means
> something different. My query expresses "number of miles this pet is
> from 90210", while I think the refactor expresses a distance between a
> pet and another calculated value.

my mistake, i misunderstood what you were trying to do...can you try
removing the 'order by radius' and see if it helps? if not, we can try
working on this query some more.  There is a better, faster way to do
this, I'm sure of it.

merlin

В списке pgsql-performance по дате отправления:

Предыдущее
От: Heikki Linnakangas
Дата:
Сообщение: Re: many instances or many databases or many users?
Следующее
От: "Merlin Moncure"
Дата:
Сообщение: Re: cube operations slower than geo_distance() on production server