Re: Feedback about Drupal SQL debugging

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Stephen Frost <sfrost(at)snowman(dot)net>
Cc: Jean-Michel Pouré <jm(at)poure(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Feedback about Drupal SQL debugging
Date: 2009-08-22 01:01:35
Message-ID: 407d949e0908211801y2648dedcrd4d5f1494939e24c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2009/8/22 Stephen Frost <sfrost(at)snowman(dot)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,b
GROUP 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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Stephen Frost 2009-08-22 01:09:04 Re: Feedback about Drupal SQL debugging
Previous Message Greg Stark 2009-08-22 00:56:12 Re: EXPLAIN VERBOSE vs resjunk output columns