DB/Query optimization:
I had the opportunity to review the mysql-slow.log from a large practice using OpenEMR and there were some queries that are causing bottlenecks. Can anyone look at these and help decide what needs to be added, such as indexes to these tables to speed them up?
# Time: 2019-05-20T15:02:37.392370Z
# User@Host: openemr[openemr] @ localhost Id: 148154
# Query_time: 8.207200 Lock_time: 0.000313 Rows_sent: 0 Rows_examined: 1310764
SET timestamp=1558364557;
SELECTvalue
FROMclinical_rules_log
WHEREcategory
= ‘clinical_reminder_widget’ ANDpid
= 116354 ANDuid
= ‘2053’ ORDER BYid
DESC LIMIT 1;
# Time: 2019-05-20T15:03:21.818403Z
# User@Host: openemr[openemr] @ localhost Id: 148103
# Query_time: 8.551393 Lock_time: 0.000181 Rows_sent: 1 Rows_examined: 135721
SET timestamp=1558364601;
SELECT id, form_id, content FROM form_repository WHERE pid=158426 AND form_id=‘71101’ AND form_name=‘form_ped_comp1’ AND encounter=935930;
# Time: 2019-05-20T16:23:46.532411Z
# User@Host: openemr[openemr] @ localhost Id: 199866
# Query_time: 7.751776 Lock_time: 0.000407 Rows_sent: 0 Rows_examined: 1312033
SET timestamp=1558369426;
SELECTvalue
FROMclinical_rules_log
WHEREcategory
= ‘clinical_reminder_widget’ ANDpid
= 1000000000001775 ANDuid
= ‘2053’ ORDER BYid
DESC LIMIT 1;