The following bug has been logged on the website:
Bug reference: 16254
Logged by: Алексей Божков
Email address: smartyru@gmail.com
PostgreSQL version: 10.5
Operating system: CentOS Linux release 7.5.1804 (Core)
Description:
After refactoring of a SQL query during run of new version of the query
given below
select count( distinct case when proc_error_cd = '000' then 'ok@' end ||
muid || '@' || email ),
count( distinct case when proc_error_cd = '000' then null else 'err@' end ||
muid || '@' || email )
into v_in_cnt, v_in_cnt_err
from cb.T co
where check_dt_msk between v_check_dt_min and v_check_dt_max
and cashback <> 0
and calc_batch_id = any(v_calc_batch_id_ar)
and muid = any (v_muid_ar);
where
v_muid_ar, v_calc_batch_id_ar - are arrays of (183 and 4167 scalar elements
populated below)
select array_agg(distinct muid)
into v_muid_ar
from cb.rsp_tst
where txncode in ('29', '18')
and tsid::int = v_tsid;
select array_agg(distinct calc_batch_id)
into v_calc_batch_id_ar
from cbf.calc_batch_dt_range
where batch_group_id = v_tsid;
I got error dsa_allocate could not find 4 free pages
Old version of query runs without errors:
select count( distinct case when proc_error_cd = '000' then 'ok@' end ||
muid || '@' || email ),
count( distinct case when proc_error_cd = '000' then
null else 'err@' end || muid || '@' || email )
into v_in_cnt, v_in_cnt_err
from cb.T co, cbf.calc_batch_dt_range rn
where 1=1
and check_dt_msk between v_check_dt_min and
v_check_dt_max
and cashback <> 0
and co.calc_batch_id = rn.calc_batch_id
and batch_group_id = v_tsid
and muid in ( select unnest ( v_muid_ar ) );
cb.T is a view of a few mln rows