Performance Degradation in Oracle Paginated Query with Bind Variables via OJDBC
I'm facing a performance issue with the following paginated query:
SELECT a.*
FROM (
SELECT task_desc,
task_id,
aircraft_sdesc,
inventory_desc,
soft_deadline,
is_estop,
'GetMxTask' luname
FROM ad_task_search_dm
) a
OFFSET 24 ROWS FETCH FIRST 25 ROWS ONLY;
When investigating the above performance issue, I found out that the query executes efficiently in tools like PL/SQL Developer, since it's using
string literals.
However, the same query takes significantly longer when using bind variables in the application.
And another thing is that the query is much faster without OFFSET value.
As a temporary workaround, I’ve considered applying query hints to force specific execution paths. However, I’m concerned that using hints generically may negatively impact other areas of the application.