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:31:57
Message-ID: 407d949e0908211831r18cb498av5fc172b96210317f@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>:
> * Greg Stark (gsstark(at)mit(dot)edu) wrote:
>> 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
>
> Ahhh, ok, this makes more sense.  This is SQL standard?

Incidentally it makes even more sense that MySQL would do what they do
when you remember that they didn't have subqueries until recently. So
MySQL programmers had all become accustomed to the circumlocutions
like:

SELECT a.*
FROM a left join b USING (a.b_id = b.id)
WHERE b.id IS NULL
GROUP BY a.id

to express the much simpler

select * from a where b_id in (select id from b)

So not many uses of it in MySQL actually *would* be valid if we
implemented the shortcut. But MySQL doesn't enforce that so it serves
that purpose as well as what we get out of DISTINCT ON.

--
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:36:06 Re: Feedback about Drupal SQL debugging
Previous Message Stephen Frost 2009-08-22 01:31:44 Re: Feedback about Drupal SQL debugging