Re: slow performance with cursor

2021-07-02 Thread Tomas Vondra
On 7/1/21 10:25 PM, Ayub Khan wrote: > Justin, > > Below is the stored procedure, is there any scope for improvement? > Hard to say, based on just the stored procedure source code. The queries are not too complex, but we don't know which of them gets selected for each cursor, and which of them i

Re: slow performance with cursor

2021-07-01 Thread Ayub Khan
Justin, Below is the stored procedure, is there any scope for improvement? CREATE OR REPLACE PROCEDURE "new_api_pkg$get_menu_details_p"( i_user_id bigint, i_menu_item_id bigint, INOUT o_menu refcursor, INOUT o_item refcursor, INOUT o_choice refcursor) LANGUAGE 'plpgsql' AS $BODY$ BEGIN IF i_u

Re: slow performance with cursor

2021-07-01 Thread Justin Pryzby
On Fri, 25 Jun 2021, 19:09 Ayub Khan, wrote: > I am using postgresql 12 and using cursors in a stored procedure, > executing procedure which has cursor is slowing down the call. However if I > do not use the cursor and just execute the queries using JDBC (Java client) > it's fast. > > Is there any

Re: slow performance with cursor

2021-07-01 Thread Ayub Khan
I set the cursor_tuple_fraction to 1 now I am seeing high cpu for fetach all in The number of rows returned is less than 200. Why is the high cpu being shown for fetch all -Ayub On Fri, 25 Jun 2021, 19:09 Ayub Khan, wrote: > > I am using postgresql 12 and using cursors in a stored procedure,

Re: slow performance with cursor

2021-06-25 Thread Tom Lane
Ayub Khan writes: > Is there any setting which needs to be modified to improve the performance > of cursors. Also facing slow response with reading blobs (images) from db. > Not an ideal way for storing images in db but this is a legacy application > and wanted to check if there a quick tweak whic

Re: slow performance with cursor

2021-06-25 Thread Ayub Khan
slowness is on the database side as I see the CPU goes high for procedures returning the result using cursors. If the same query is executed as a prepared statement from Java client there is no slowness. for example there are 84 rows returning all are text data from a query. If the result is retur

Re: slow performance with cursor

2021-06-25 Thread Justin Pryzby
On Fri, Jun 25, 2021 at 07:09:31PM +0300, Ayub Khan wrote: > I am using postgresql 12 and using cursors in a stored procedure, > executing procedure which has cursor is slowing down the call. However if I > do not use the cursor and just execute the queries using JDBC (Java client) > it's fast. Is

slow performance with cursor

2021-06-25 Thread Ayub Khan
I am using postgresql 12 and using cursors in a stored procedure, executing procedure which has cursor is slowing down the call. However if I do not use the cursor and just execute the queries using JDBC (Java client) it's fast. Is there any setting which needs to be modified to improve the perfor