Re: Feedback about Drupal SQL debugging - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Feedback about Drupal SQL debugging
Date
Msg-id 407d949e0908211801y2648dedcrd4d5f1494939e24c@mail.gmail.com
Whole thread Raw
In response to Re: Feedback about Drupal SQL debugging  (Stephen Frost <sfrost@snowman.net>)
Responses Re: Feedback about Drupal SQL debugging  (Stephen Frost <sfrost@snowman.net>)
List 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 by date:

Previous
From: Greg Stark
Date:
Subject: Re: EXPLAIN VERBOSE vs resjunk output columns
Next
From: Stephen Frost
Date:
Subject: Re: Feedback about Drupal SQL debugging