Re: Can simplify 'limit 1' with slow function?

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Can simplify 'limit 1' with slow function?
Дата
Msg-id 20140701191631.GA20140@svana.org
обсуждение исходный текст
Ответ на Can simplify 'limit 1' with slow function?  ("gotoschool6g" <gotoschool6g@gmail.com>)
Ответы Re: Can simplify 'limit 1' with slow function?  (Merlin Moncure <mmoncure@gmail.com>)
Список pgsql-hackers
On Sun, Jun 29, 2014 at 10:05:50PM +0800, gotoschool6g wrote:
> The simplified scene:
> select slowfunction(s) from a order by b limit 1;
> is slow than
> select slowfunction(s) from (select s from a order by b limit 1) as z;
> if there are many records in table 'a'.
>
>
> The real scene. Function  ST_Distance_Sphere is slow, the query:
> SELECT ST_Distance_Sphere(s, ST_GeomFromText('POINT(1 1)')) from road order by c limit 1;
> is slow than:
> select ST_Distance_Sphere(s, ST_GeomFromText('POINT(1 1)')) from (SELECT s from road order by c limit 1) as a;
> There are about 7000 records in 'road'.

I think to help here I think we need the EXPLAIN ANALYSE output for
both queries.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> He who writes carelessly confesses thereby at the very outset that he does
> not attach much importance to his own thoughts.  -- Arthur Schopenhauer

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Spinlocks and compiler/memory barriers
Следующее
От: Dean Rasheed
Дата:
Сообщение: Re: RLS Design