Ran into an interesting problem on a production OpenEMR instance earlier this week, where the SQL server load starting creeping up, eventually tripling the normal average, and the UI response time cratered.
Analysis of the SQL logs revealed that the table queries generated in vitals_fragment.php were now taking an average of 14-20 seconds to complete, which was creating a cascading database overload effect and dragging the system performance down across the board.
Suggest making the following change on line 25 of âŚ/interface/patient_file/summary/vitals_fragement.php -
//retrieve most recent set of vitals
$result=sqlQuery(âSELECT FORM_VITALS.date, FORM_VITALS.id FROM form_vitals AS FORM_VITALS LEFT JOIN forms AS FORMS ON FORM_VITALS.id = FORMS.form_id AND FORMS.pid = FORM_VITALS.pid AND FORMS.formdir LIKE âvitalsâ WHERE FORM_VITALS.pid=? AND FORMS.deleted != â1â ORDER BY FORM_VITALS.date DESCâ, array($pid) );
The original version of that query processes the entire forms table, rather than specifying only vitals.
Since that query executes every time someone loads a patient, it can really pile up on a busy EMR.
In this case, the production database contains close to 7 millions forms records and nearly a half million Vitals records. Refining that query took the average SQL processing time from 15-20 seconds, to under 2 seconds every time a patientâs demographic summary is opened. Reviewing past releases, it looks like that particular vitals query has been basically unchanged since back in the version 4 days, so no surprise it eventually turned into a problem.
This might not present an issue for smaller low volume practices, but eventually as data accumulates over time it will affect almost any system thatâs been in use long enough to gather a significant patient visit history.