I have the following oracle table (minimal for this question)
create table my_table
(
selecting_by NUMBER(10),
wanted_value VARCHAR(100),
)
And the following SELECTs:
-- Select as strings
SELECT wanted_value as wv FROM my_table WHERE selecting_by IN ('1', '2', '3');
-- Select as numbers
SELECT wanted_value as wv FROM my_table WHERE selecting_by IN (1, 2, 3);
It turns out, for every Oracle DB (job’s production db and locally a smaller PoC on my laptop) the first query is faster than the second one (on my PC it was 2 times faster, and in production is 30 times faster, which is not negligible).
These are some statistics that I extracted from my PoC:
- LongSummaryStatistics{count=800, sum=78002, min=58, average=97.502500, max=690}
- LongSummaryStatistics{count=800, sum=136886, min=59, average=171.107500, max=3654}
The code runs in java (both production and personal) and from what I seen on JProfiler, the issue is from query execution (not query creation/building).
12