Re: Slow query: table iteration (8.3)

Поиск
Список
Период
Сортировка
От Glenn Maynard
Тема Re: Slow query: table iteration (8.3)
Дата
Msg-id bd36f99e1002051735i32a2c86blb295ea9edea89547@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Slow query: table iteration (8.3)  (Yeb Havinga <yebhavinga@gmail.com>)
Ответы Re: Slow query: table iteration (8.3)  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-performance
On Fri, Feb 5, 2010 at 6:17 AM, Yeb Havinga <yebhavinga@gmail.com> wrote:
> and the cache is used between each row of test_users. The plan is with a
> parameter, that means the optimizer could not make use of an actual value
> during planning. However, your test case is clever in the sense that there
> is an index on users and score and the sql function has an order by that
> matches the index, so the planner can avoid a sort by accessing the test
> table using the index.

That's why the index exists.  The point is that the window function
doesn't use the index in this way, and (I think) does a complete index
scan.

It's not just about avoiding a sort, but avoiding touching all of the
irrelevant data in the index and just index searching for each
user_id.  The window function appears to scan the entire index.  In
principle, it could skip all of the "rank() > 1" data with an index
search, which I'd expect to help many uses of rank(); I assume that's
just hard to implement.

I'll probably be implementing the "temporary functions" approach
tonight, to help Postgres optimize the function.  Maybe some day,
Postgres will be able to inline functions in this case and that won't
be needed...

--
Glenn Maynard

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

Предыдущее
От: Robert Haas
Дата:
Сообщение: Re: index on partitioned table
Следующее
От: Greg Smith
Дата:
Сообщение: Re: [HACKERS] Re: Faster CREATE DATABASE by delaying fsync (was 8.4.1 ubuntu karmic slow createdb)