I am trying to tune the one query to increase the performance of the stored function by removing the distinct keyword.
in the process of query tuning, I came across the query in the stored function where the distinct keyword is using due to that performance is degrading, so I am trying to write the query with same functionality without using a distinct keyword.
Current code with distinct keyword:-
select distinct dm.strdatadest
from PUBLIC.temp te1
JOIN PUBLIC.applicationconfiguration AC on AC.intapplicationid = te1.applicationid
JOIN columnmapping cm on cm.intapplicationid = AC.intapplicationid
JOIN datamapping dm on lower(dm.strcolumnsource) = lower(cm.strcolumnsource)
JOIN srctable s on s.applicationid=AC.intapplicationid
where lower(cm.strtablesource) = lower(s.tablename) and
lower(dm.strdatasource) = lower('||quote_literal(rec.status) ||') and lower( dm.strcolumndest ) LIKE ''strstatus'' and te1.applicationid='||quote_literal(rec.applicationid);
Trying code by removing distinct keyword:-
select dm.strdatadest
from PUBLIC.temp te,
PUBLIC.applicationconfiguration AC,
PUBLIC.columnmapping cm,
PUBLIC.datamapping dm
where AC.intapplicationid = te.applicationid and cm.intapplicationid = AC.intapplicationid and lower(dm.strcolumnsource) = lower(cm.strcolumnsource)
and lower(cm.strtablesource) = lower(s.tablename) and
lower(dm.strdatasource) = lower('||quote_literal(rec.priority) ||') and lower( dm.strcolumndest ) LIKE ''strpriority'' and te1.applicationid='||quote_literal(rec.applicationid)
GROUP BY dm.strdatadest;
i required some sujjestion who to tune query by removing distinct keyword