I am using Sybase Adaptive Server Enterprise (ASE) 16. I am using jConnect 4 in version 7.07.
I have a stored procedure that contains a rather simple query, equivalent to this one (I have changed the column names):
select o.item_id, o.option_uuid, c.product_description, o.option_size
from options_rm o
left join options_products_rm c on c.id = o.product_id
where o.item_id = @item_id
I have implemented metrics in Java using Micrometer.
At peak load, the procedure is called about 1200 times in 30 seconds. On average, the procedure takes about 1.31 ms to complete.
I have then replaced the stored procedure with a prepared statement using the exact same SQL query.
After measuring with Micrometer in Java, the prepared statement takes about 1.8 ms to complete.
Even though 1.8 ms is still fast, the prepared statement takes about 37 % longer than the stored procedure. The same phenomenon happens when applied to other stored procedures.
Here is a quick rundown of the Sybase ASE database setup:
- Since I am using jConnect 4,
DYNAMIC_PREPAREshould be true by default. - The
statement cache sizeis set to 2048 memory pages (2K). - The memory used of
statement cache sizeis 4784 kilobytes. streamlined dynamic SQLis enabled.
Why does the prepared statement take so much longer than the procedure, even though its execution plan etc. should already be cached?
How can I improve the performance of prepared statements on Sybase ASE?
dynamic sql plan pinningprovide any benefit; wondering if this is contention on the query plan mgr and if each connection can benefit from re-using its own query plan?enable literal autoparam,dynamic sql plan pinning,enable plan sharing; also, any chance you're submitting SQL comments with each query (ASE, unfortunately, treats comments as part of 'the code' such that different comments look to ASE like different code => each requiring a new plan)dynamic SQL plan pinningis set to0.enable literal autoparamis set to1.enable plan sharingis set to0. I will compare it to "normal" statements next week.