How to fix the performance issue with the in operator.
SELECT *
FROM Q1
WHERE Q1.sample IN (SELECT COLUMN_VALUE
FROM TABLE(APEX_STRING.SPLIT(NVL(:P34_ACC,Q1.sample ),',')))
You are using a function to generate rows in your IN clause. Oracle cannot know whether this will result in say, one or two rows or five billion rows. Thus it can only come up with a general execution plan, that may or may not be good.
You can hint Oracle as to the number of expected rows using the undocumented CARDINALITY hint:
SELECT *
FROM Q1
WHERE Q1.sample IN
(
SELECT /*+cardinality(t, 10)*/ COLUMN_VALUE
FROM TABLE( APEX_STRING.SPLIT(NVL(:P34_ACC,Q1.sample ),',')) t
);
For the case of few rows, you should have an index on Q1.sample:
CREATE INDEX idx ON q1(sample);
mysql,postgresql,sql-server,oracleordb2- or something else entirely.