-- insert skycells to diff 
INSERT INTO skycellsToDiff
    SELECT
        0,              -- diff_id
        warpSkyfile.skycell_id,
        warp_id,        -- warp1
        NULL,           -- stack1
        NULL,           -- warp2
        max_stack_id,   -- stack2
        warpSkyfile.tess_id
        FROM warpSkyfile
        JOIN warpRun USING(warp_id)
        LEFT JOIN (
            SELECT
                MAX(stack_id) AS max_stack_id, -- most recent stack, by virtue of auto-increment
                stackRun.skycell_id,
                stackRun.tess_id,
                filter
            FROM stackRun
            JOIN stackSumSkyfile USING(stack_id)
            -- stacks where hook %s
            GROUP BY 
                skycell_id,
                filter
            ) as bestStacks
        USING(skycell_id)
        WHERE
            warp_id = %lld
            AND ignored = 0
            AND filter = '%s'
            AND warpSkyfile.tess_id = bestStacks.tess_id
        -- (good fraction test goes here for example also above)
        -- warp where hook %s
