IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 18609


Ignore:
Timestamp:
Jul 17, 2008, 4:12:41 PM (18 years ago)
Author:
Paul Price
Message:

That ORDER BY which I claimed was so important wasn't really. I think I was in shaky ground so far as standard SQL is concerned (undefined behaviour). By explicitly taking the MAX, I don't need to ORDER BY and then hope that it chooses the right one. Besides, MAX is faster than ORDER BY.

Location:
trunk/ippTools/share
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/share/stacktool_definebyquery_part1.sql

    r18579 r18609  
    44
    55SELECT
    6     *
     6    skycell_id,
     7    tess_id,
     8    filter,
     9    num_warp,
     10    MAX(num_stack) AS num_stack
    711FROM ((
    812    -- Number of stack-ready warps as a function of skycell and filter
  • trunk/ippTools/share/stacktool_definebyquery_part2.sql

    r18579 r18609  
    2020    GROUP BY
    2121        stack_id
    22     -- This ORDER BY is important: it sets the final num_stack that
    23     -- comes out of the top-level GROUP BY.  We want it to be the
    24     -- biggest number for a skycell/filter combination.
    25     ORDER BY
    26         num_stack DESC
    2722        ) AS stackSizes
    2823    -- JOINing the warpsToStack and stackSizes tables
  • trunk/ippTools/share/stacktool_definebyquery_test.sql

    r18579 r18609  
    1111-- stacktool_definebyquery_part1.sql
    1212SELECT
    13     *
     13    skycell_id,
     14    tess_id,
     15    filter,
     16    num_warp,
     17    MAX(num_stack) AS num_stack
    1418FROM ((
    1519    -- Number of stack-ready warps as a function of skycell and filter
     
    3034    AND warpSkyfile.fault = 0
    3135    -- Any additional selection on warps/exposures goes here
    32 
    3336-- stacktool_definebyquery_part2.sql
    3437    GROUP BY
     
    4245        tess_id,
    4346        filter,
    44         stack_id,
    4547        COUNT(stackInputSkyfile.warp_id) as num_stack -- number of warps in a stack
    4648    FROM stackRun
     
    4850    GROUP BY
    4951        stack_id
    50     -- This ORDER BY is important: it sets the final num_stack that
    51     -- comes out of the top-level GROUP BY.  We want it to be the
    52     -- biggest number for a skycell/filter combination.
    53     ORDER BY
    54         num_stack DESC
    5552        ) AS stackSizes
    5653    -- JOINing the warpsToStack and stackSizes tables
Note: See TracChangeset for help on using the changeset viewer.