Subject | Re: Master-Detail query help, please... :) |
---|---|
Author | Greg At ACD |
Post date | 2005-09-30T15:41:37Z |
--- In firebird-support@yahoogroups.com, Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
Thx for the help!
The slowdown with DISTINCT M.* isn't necessarily due to a large
result set, but more to do that M.* has quite a few columns (and I
do need them returned in this case). The distinction is only needed
on the PK, yet the DISTINCT qualifier will work through all columns
in the result set to find any differences.
Greg
<svein.erling.tysvaer@k...> wrote:
> Hmm, I doubt this is quicker to return the full data set, but maybe
> quicker to return the first few records:clause.
>
> SELECT M.*
> FROM TableMaster M
> INNER JOIN TableChild C ON M.MID = C.MID
> WHERE C.SomeValue IN (A, B)
> AND NOT EXISTS(SELECT * FROM TableChild C2
> WHERE M.MID = C2.MID
> AND C2.SomeValue < C.SomeValue)
>
> i.e. simply move the DISTINCT from the SELECT clause to the WHERE
>the
> But a better approach would of course be to return fewer records in
> the first place, a DISTINCT that appears slow indicates that you
> select a larger result set than would normally be appropriate for
> anything but batch processing (or that I'm not quite understanding
> problem).Hi,
>
> HTH,
> Set
Thx for the help!
The slowdown with DISTINCT M.* isn't necessarily due to a large
result set, but more to do that M.* has quite a few columns (and I
do need them returned in this case). The distinction is only needed
on the PK, yet the DISTINCT qualifier will work through all columns
in the result set to find any differences.
Greg