DB2 Aggregate SubQuery across unions performance

This is very slow:

    select F_KEY, count(*) as P1FM_F_KEY_C
    from (
     select FILE_KEY as F_KEY from NPFP1.NPF_FILE_MIGRATION
     where FILE_KEY IS NOT NULL
     union all
     select FILE_ERROR_KEY as F_KEY from NPFP1.NPF_FILE_MIGRATION
     WHERE FILE_ERROR_KEY IS NOT NULL
     ) FK
    GROUP By F_KEY

This is much faster

select F_KEY, sum(P1FM_F_KEY_C) as P1FM_F_KEY_C from (
  select FILE_KEY as F_KEY, count(*) as P1FM_F_KEY_C
  from NPFP1.NPF_FILE_MIGRATION
  group by FILE_KEY
  union all
  select FILE_ERROR_KEY as F_KEY, count(*) as P1FM_F_KEY_C
  from NPFP1.NPF_FILE_MIGRATION
  group by FILE_ERROR_KEY
 ) T
group by F_KEY