Re: Feedback about Drupal SQL debugging

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Feedback about Drupal SQL debugging
Дата
Msg-id 407d949e0908211801y2648dedcrd4d5f1494939e24c@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Feedback about Drupal SQL debugging  (Stephen Frost <sfrost@snowman.net>)
Ответы Re: Feedback about Drupal SQL debugging  (Stephen Frost <sfrost@snowman.net>)
Список pgsql-hackers
2009/8/22 Stephen Frost <sfrost@snowman.net>:
> Hrmm.  That sounds kinda neat, but you'd still have to specify one of
> the columns in the GROUP BY, I presume?  Or could you just say 'GROUP
> BY' without any columns, and have it GROUP BY the key of the table
> you're using?

You would have to specify the key. I think typically you would have
something like:

SELECT a.*, sum(b.col)  FROM a,bGROUP BY a.pk

Since you have the primary key of a in your group by column you're
allowed to use any columns from a in your select list even if they're
not listed in the group by clause.

The database knows that it can use those values from any output row of
the group since they'll all come from the same orginal row of a. Or
possibly it could use some plan that doesn't involve multiplying that
data in the first place.

--
greg
http://mit.edu/~gsstark/resume.pdf


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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: EXPLAIN VERBOSE vs resjunk output columns
Следующее
От: Stephen Frost
Дата:
Сообщение: Re: Feedback about Drupal SQL debugging