"Johnson, Shaunn" <SJohnson6@bcbsm.com> writes:
> explain
> select *
> -- INTO dev_gm_er_prof01
> FROM
> db2_gm_reg_prof_01
> WHERE
> db2_gm_reg_prof_01.place_of_service = 2 and
> db2_gm_reg_prof_01.diagnosis_cd not like '29%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '30%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '310%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '311%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '312%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '313%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '314%' and
> db2_gm_reg_prof_01.diagnosis_cd not like '315%' and
> db2_pos_reg_prof_01.diagnosis_cd not like '316%'
^^^
Isn't that a typo?
> Is this *really* supposed to bring back 4587594094 rows into this
> table they are trying to create?
If the two tables indeed have ~2K and ~2M rows respectively, then yes,
an unconstrained join of the two will yield ~4G rows ...
regards, tom lane