Re: Why is query selecting sequential?

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Why is query selecting sequential?
Дата
Msg-id 200402061436.57903.josh@agliodbs.com
обсуждение исходный текст
Ответ на Re: Why is query selecting sequential?  (Karl Denninger <karl@denninger.net>)
Ответы Re: Why is query selecting sequential?
Список pgsql-performance
Karl,

Well, still with only 5 rows in the forumlog table you're not going get
realistic results compared to a loaded database.  However, you are making
things difficult for the parser with awkward query syntax; what you currently
have encourages a sequential loop.

If there are potentially several rows in forumlog for each row in post, then
your query won't work either.

> akcs=> explain analyze select forum, (replied > (select lastview from
forumlog where forumlog.login='genesis' and forumlog.forum='General' and
number=post.number)) as newflag, * from post where forum = 'General' and
toppost = 1 order by pinned desc, replied desc;

Instead:

if only one row in forumlog per row in post:

SELECT (replied > lastview) AS newflag, post.*
FROM post, forumlog
WHERE post.forum = 'General' and toppost = 1 and forumlog.login = 'genesis'
and forumlog.forum='General' and forumlog.number=post.number;

--
-Josh Berkus
 Aglio Database Solutions
 San Francisco


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

Предыдущее
От: Karl Denninger
Дата:
Сообщение: Re: Why is query selecting sequential?
Следующее
От: Orion Henry
Дата:
Сообщение: Re: 7.3 vs 7.4 performance