db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bryan Pendleton (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DERBY-3613) SELECT DISTINCT field FROM TABLE_NAME GROUP BY field, field2
Date Sun, 20 Apr 2008 02:46:23 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3613?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12590731#action_12590731

Bryan Pendleton commented on DERBY-3613:

This page suggests that certain versions of Sybase may have similar behavior to Derby:


It seems like Derby could recognize that:

  select distinct a from t group by a, b

is identical to

  select distinct a from t group by a

I can think of 3 possible ways to give Derby this behavior:
1) When processing GROUP by columns, and deciding whether to pull them up
into the result column list as generated columns, detect this particular case and
don't pull up the generated GROUP BY column "b" into the result list.
2) In the compilation process, prior to generating the distinct scan result set,
detect that un-necessary column "b" has been included into the result column list
and skip it when generating the data structures for execution.
3) At execution time, when setting up the sorter, recognize that column "b" isn't
needed in the sort key, and only sort/collapse the records on column "a".

It seems best to detect this situation earlier rather than later, so I'm partial
to solutions which can solve the problem at compilation time, not execution time.

> -------------------------------------------------------------
>                 Key: DERBY-3613
>                 URL: https://issues.apache.org/jira/browse/DERBY-3613
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions:
>         Environment: Windows XP
>            Reporter: Artur Kuś
> Query 'SELECT DISTINCT field FROM TABLE_NAME GROUP BY field,  field2'  not work ok.
>  Distinct is ignored !!!

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message