I have this 15 postgres sql queries similar to below to run in linux... Its taking a lot of time to run (3hours) .
can any one plz guide me how can i reduce the time of execution
execute 'insert into cc.rpt_cons_sub_ccdb_data(report_date, server_name, report_type, count)
select date(timestamp), '||chr(39)||'1.5 S30'||chr(39)||', '||chr(39)||'1.5 S30 Combo Natural Activations'||chr(39)||', count(id) from cc.transaction
where serverid in ('||chr(39)||'NLTAD'||chr(39)||')
and date(timestamp) ='||chr(39)||rpt_start_date||chr(39)||' and state=4
and type in (18,31) group by 1 order by 1';
raise notice 'Completed populating 1.5 S30 Combo Natural Activations to rpt_cons_sub_ccdb_data table';
execute 'insert into cc.rpt_cons_sub_ccdb_data(report_date, server_name, report_type, count)
select date(timestamp), '||chr(39)||'1.5 S30'||chr(39)||', '||chr(39)||'1.5 S30 Paid Activations'||chr(39)||', count(id) from cc.transaction
where serverid in ('||chr(39)||'NLTAD'||chr(39)||')
and date(timestamp) ='||chr(39)||rpt_start_date||chr(39)||' and state=4
and type in (19) group by 1 order by 1';
raise notice 'Completed populating 1.5 S30 Paid Activations to rpt_cons_sub_ccdb_data table';