# Form\_vitals is taking much longer to execute

**URL:** <https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138>\
**Category:** OpenEMR Development\
**Created:** [August 1, 2012, 1:43pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138 "2012-08-01T13:43:52Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 1:43pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/1 "2012-08-01T13:43:52Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#360a):

I am not sure if this qualifies as a bug or not but when we recently upgraded from 4.1.0 to 4.1.0 patch 11 we noted that the form\_vitals is taking much longer to execute than before the upgrade.&nbsp; Is there any indexing that should be applied to&nbsp; this form possibly on the pid field?

Sam Bowen, MD  
OEMR

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 1:52pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/2 "2012-08-01T13:52:58Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#2c50):

Previously this executed very quickly, possible just 1-2 seconds but not the query takes 14-15 seconds to execute.

Software versions  
Ubuntu current  
mysql&nbsp;&nbsp; 5.1.61-0ubuntu0.10.10.1 (Ubuntu)  
apache2&nbsp;&nbsp; 2.2.16-1ubuntu3.5  
PHP&nbsp; 5.3.3-1ubuntu9.10 with Suhosin-Patch

hardware:  
ASUS quad opteron  
8 Gigabyte RAM

Sam Bowen, MD  
OEMR

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 1:55pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/3 "2012-08-01T13:55:07Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#2813):

What action exactly is taking a long time?

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 3:33pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/4 "2012-08-01T15:33:50Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#f822):

Once we have started an encounter we normally use the the “clinical” drop down box to select the forms that we want to use.

In the drop down box we click on form\_vitals.&nbsp; It takes 14-17 seconds for the form to be displayed on the screen.&nbsp; This has the blank form on the left and all the historic vitals displayed to the right.

After entering data into the form\_vitals and saving the data, if we need to reopen the form by clicking on the edit button:

[http://myofficeserver/openemr/interface/patient\_file/encounter/view\_form.php?formname=vitals&id=315529](http://myofficeserver/openemr/interface/patient_file/encounter/view_form.php?formname=vitals&id=315529)

The form takes 14-17 seconds before it displays on the screen.&nbsp; The recently entered vital sign data on the left and all the historic vital signs to the right.

Currently we have 315,550 records in the form\_vitals table.

Sam Bowen, MD  
OEMR

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 3:43pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/5 "2012-08-01T15:43:09Z")

</div>

**[yehster](https://sourceforge.net/u/yehster/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#ae66):

I suspect that this commit  
[https://github.com/openemr/openemr/commit/5bb5bffd9dd04f0632bdd01ee0f62e4982492ebd#interface/forms/vitals/C\_FormVitals.class.php](https://github.com/openemr/openemr/commit/5bb5bffd9dd04f0632bdd01ee0f62e4982492ebd#interface/forms/vitals/C_FormVitals.class.php)  
is the source of your performance issues.&nbsp; It adds an additional join with the form\_encounter table  
Indicies on the encounter columns in forms and form\_encounter tables might help.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 4:18pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/6 "2012-08-01T16:18:03Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#6770):

I’d suggest adding an index on form\_vitals.pid and perhaps also on forms.form\_id.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 4:31pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/7 "2012-08-01T16:31:52Z")

</div>

**[yehster](https://sourceforge.net/u/yehster/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#fd32):

Rod, The indicies you suggest should already exist.&nbsp;

I suspect that the new composite pid\_encounter index you added:  
[https://github.com/openemr/openemr/commit/99fb6cff7c11090d5ff86ef0b6c9cd1075e7f4bc#sql/database.sql](https://github.com/openemr/openemr/commit/99fb6cff7c11090d5ff86ef0b6c9cd1075e7f4bc#sql/database.sql)  
in 4.1.1 would likely also address Dr. Bowen’s issue.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 4:42pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/8 "2012-08-01T16:42:14Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#87a2):

They are not on the 4.1.0 demo site at [http://demo.open-emr.org:2100/openemr/](http://demo.open-emr.org:2100/openemr/) .&nbsp; Sam, are they present on your site?

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 6:12pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/9 "2012-08-01T18:12:35Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#e2e6):

Currently I am showing Indexes on colums \*\* id, pid\*\* on **forms, form\_encounters, form\_vitals**

Sam Bowen

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 6:33pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/10 "2012-08-01T18:33:14Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#b3dc):

OK try creating an index for form\_id on the forms table.&nbsp; And as Kevin suggested, indexes for encounter on forms and form\_encounter.&nbsp; Do them one at a time so we know which one matters the most.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 7:54pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/11 "2012-08-01T19:54:50Z")

</div>

**[yehster](https://sourceforge.net/u/yehster/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#08bf):

Since the column form\_id in forms has an informal “foreign key” relationship with all of the id column form\_\* tables, indexing that column probably makes sense even outside the context of this issue.&nbsp;

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 8:49pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/12 "2012-08-01T20:49:50Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#1fa7):

Wooah….!

Paydirt!

I added

form\_id INDEX 188210&nbsp; form\_id

and now the table is lightning fast again.&nbsp; Much less than 1 second.&nbsp; Technically the form comes up / blinks faster than I can measure.

Sam Bowen, MD

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 9:04pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/13 "2012-08-01T21:04:02Z")

</div>

**[yehster](https://sourceforge.net/u/yehster/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#0130):

Glad to hear it.&nbsp; You might even notice speed up for other forms.&nbsp; I suspect that adding an index on “encounter” would have brought your system’s “old performance” back (1-2 seconds).&nbsp; However the code routinely joins form\_\* id with forms form\_id, it needs to tablescan without the index.

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 9:12pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/14 "2012-08-01T21:12:28Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#2f6e):

High five Sam. 😉

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 9:12pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/15 "2012-08-01T21:12:38Z")

</div>

**[drbowen](https://sourceforge.net/u/drbowen/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#a0a1):

Do you guys want me to try the other indices one at a time?

Not sure, but can I remove the the form\_id to allow testing of the other two indices?

Sam Bowen, MD

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 1, 2012, 9:14pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/16 "2012-08-01T21:14:28Z")

</div>

**[sunsetsystems](https://sourceforge.net/u/sunsetsystems/)** wrote on [Wednesday, August 01, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#9db3):

I think we’ve found the answer but you could if you like.

Rod  
[www.sunsetsystems.com](http://www.sunsetsystems.com)

---

<div class="post-metadata">

**Author:** ![system](https://discourse-uploads-openemr.s3.dualstack.us-east-1.amazonaws.com/original/2X/b/bb9e4e8ae2ea7faac2e952fd9e38a3ce03aac403.png) [@system](https://community.open-emr.org/u/system)\
**Post date:** [August 4, 2012, 5:18pm UTC](https://community.open-emr.org/t/form-vitals-is-taking-much-longer-to-execute/6138/17 "2012-08-04T17:18:54Z")

</div>

**[bradymiller](https://sourceforge.net/u/bradymiller/)** wrote on [Saturday, August 04, 2012](https://sourceforge.net/p/openemr/discussion/202506/thread/77e888be/#eca6):

Hi,  
Just committed this fix to sourceforge (both the master and rel-411 branches).  
-brady  
[OpenEMR](http://www.open-emr.org/)
