Sub-panel taking time to load when expand

I am facing issue with the Sub-panel on detail view, that sub-panel is taking too much time to load (10-15 seconds) the contents when we expand the contents.

From the Admin settings I applied setting that, show only 10 rows on Sub-panel.

I also applied Indexes on the table. Still sub-panel is taking time to load the contents.

Sub-panel is contains near about 100 records.

Observation:

We found the following query is executing for each row in sub-panel. Means if there is 10 rows in panel then following query is executing for 10 times.

DECLARE @topCount INT SET @topCount = 1
SELECT TOP (@topCount) patie_appointment1.,patie_appointment1_cstm.
FROM patie_appointment1
LEFT JOIN patie_appointment1_cstm ON patie_appointment1.id = patie_appointment1_cstm.id_c
WHERE patie_appointment1.id = ‘95859e39-1a05-29e5-d594-6018f859f62c’ AND patie_appointment1.deleted=0;

Also we found bellow query which is executing unnecessarily:
DECLARE @topCount INT SET @topCount = 1
SELECT TOP (@topCount) email_addresses.*
FROM email_addresses
WHERE email_addresses.id = ‘’ AND email_addresses.deleted=0;

Please suggest on this one that how I can reduce the loading time of sub-panel.

I am using SuiteCRM Version 7.11.8

Thanks in advance.

I remeber there’s a setting to remove totals for performance reasons:

Drop the absolute totals from listviews : Eliminates performing expensive count queries on the database when populating listviews and subpanels.

$sugar_config['disable_count_query'] = true;

Try it and see what happens. But for me, it doesn’t make sense to have that query run once for each row… so maybe something else is wrong…

Thank you for the quick response. But $sugar_config[‘disable_count_query’] = true; adding this setting does not work for me. Still sub-panel is taking time to load. I have also checked for the slow query in log but I did not get any slow query as well.

Is there any other way / solution that I have to looked into ?

We’d have to debug the code of the subpanel and see why it’s generating that query for every row (assuming you didn’t add any custom code yourself).

Just out of curiosity, if you run the query at the top of this post, does anything stand out for you, anything look strange? Sometimes the problem is a general slowness in the database, caused by overgrown tables.