Long load time Middle Tier

This forum is for programmers who have questions about the source code.
Post Reply
User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Long load time Middle Tier

Post by wjstarck » Mon Dec 16, 2019 1:51 pm

The load time for one of my Winforms is greater than 30 seconds in the Middle Tier.

I have 6 different methods that refresh controls and tables, eg.

Code: Select all

			try { //null if no saved Anesthetic Record yet
				RefreshProvComboBoxes();
			}
			catch { }
Method RefreshProvComboBoxes() looks like

Code: Select all

		private void RefreshProvComboBoxes() { //This will 'Do the right thing' and show providers on old anesthetic records after they are marked 'Hidden' in OD
											   //and not include them in the provider comboboxes if they are now 'Hidden' providers
											   //Anesthetist comboBox
			List<Provider> listShort = new List<Provider>();
			listShort = Providers.GetDeepCopy(true);
			this.comboAnesthetist.Items.Clear();
			comboAnesthetist.Items.Add(Lan.g(this, ""));
			//Surgeon comboBox
			this.comboSurgeon.Items.Clear();
			comboSurgeon.Items.Add(Lan.g(this, ""));
			//Surgical assistant comboBox
			this.comboAsst.Items.Clear();
			comboAsst.Items.Add(Lan.g(this, ""));
			//Surgical assistant 2 comboBox
			this.comboAsst2.Items.Clear();
			comboAsst2.Items.Add(Lan.g(this, ""));
			//Circulator comboBox
			this.comboCirc.Items.Clear();
			comboCirc.Items.Add(Lan.g(this, ""));
			string lastAddedAnesth = String.Empty; //these prevent duplicate items from being added to list
			string lastAddedSurgeon = String.Empty;
			string lastAddedAsst = String.Empty;
			string lastAddedAsst2 = String.Empty;
			string lastAddedCirc = String.Empty;
			for (int i = 0; i < Providers.GetDeepCopy(true).Count; i++) { //ListShort is the list of non-hidden providers; ListLong is all providers
				if (AnestheticRecords.GetAnesthProvType(listShort[i].ProvNum) == 1 && AnesthLocations.IsProvider(listShort[i].ProvNum, LocationNum) == true && AnesthDataCur != null) { //Anesthetists and Surgeons																																									//refresh Anesthetist ComboBoxes
					if (AnesthDataCur.Anesthetist != String.Empty && lastAddedAnesth != AnesthDataCur.Anesthetist) {
						comboAnesthetist.Items.Add(AnesthDataCur.Anesthetist);
						lastAddedAnesth = AnesthDataCur.Anesthetist;
					}
					if (AnesthDataCur.Anesthetist != listShort[i].LName + "," + listShort[i].FName) {
						comboAnesthetist.Items.Add(listShort[i].LName + "," + listShort[i].FName);
					}
					//refresh Surgeon ComboBoxes
					if (AnesthDataCur.Surgeon != String.Empty && lastAddedSurgeon != AnesthDataCur.Surgeon) {
						comboSurgeon.Items.Add(AnesthDataCur.Surgeon);
						lastAddedSurgeon = AnesthDataCur.Surgeon;
					}
					if (AnesthDataCur.Surgeon != listShort[i].LName + "," + listShort[i].FName) {
						comboSurgeon.Items.Add(listShort[i].LName + "," + listShort[i].FName);
					}
				}
				else if (AnestheticRecords.GetAnesthProvType(listShort[i].ProvNum) == 2 && Anesthesia.Location.IsProvider(listShort[i].ProvNum, LocationNum) == true && AnesthDataCur != null) { //Assistants and Circulators																																									 //refresh Assistant ComboBoxes
					if (AnesthDataCur.Asst != string.Empty && lastAddedAsst != AnesthDataCur.Asst) {
						comboAsst.Items.Add(AnesthDataCur.Asst);
						lastAddedAsst = AnesthDataCur.Asst;
					}
					if (AnesthDataCur.Asst != listShort[i].LName + "," + listShort[i].FName) {
						comboAsst.Items.Add(listShort[i].LName + "," + listShort[i].FName);
					}
					if (AnesthDataCur.Asst2 != string.Empty && lastAddedAsst2 != AnesthDataCur.Asst2) {
						comboAsst2.Items.Add(AnesthDataCur.Asst2);
						lastAddedAsst2 = AnesthDataCur.Asst2;
					}
					if (AnesthDataCur.Asst2 != listShort[i].LName + "," + listShort[i].FName) {
						comboAsst2.Items.Add(listShort[i].LName + "," + listShort[i].FName);
					}
					//refresh Circulator ComboBoxes
					if (AnesthDataCur.Circulator != string.Empty && lastAddedCirc != AnesthDataCur.Circulator) {
						comboCirc.Items.Add(AnesthDataCur.Circulator);
						lastAddedCirc = AnesthDataCur.Circulator;
					}
					if (AnesthDataCur.Circulator != listShort[i].LName + "," + listShort[i].FName) {
						comboCirc.Items.Add(listShort[i].LName + "," + listShort[i].FName);
					}
				}
			}
			comboAnesthetist.Sorted = true;
			comboSurgeon.Sorted = true;
			comboAsst.Sorted = true;
			comboAsst2.Sorted = true;
			comboCirc.Sorted = true;
		}
This form loads within a second on a normal OD server. OD version is 19.3.34, which I recently updated to. I have been trying to port my code to Middle Tier for about 6 weeks, and I don't remember such long load times in prior versions of OD.
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

User avatar
cmcgehee
Posts: 711
Joined: Tue Aug 25, 2015 5:06 pm
Location: Salem, Oregon

Re: Long load time Middle Tier

Post by cmcgehee » Mon Dec 16, 2019 4:25 pm

We struggle with this sometimes too where Middle Tier takes much longer than a direct connection. Usually it's because someone introduced a call to Middle Tier inside a loop. A call to Middle Tier can often take 100 ms, so repeated calls really add up. My guess is that you are making a Middle Tier call in either AnestheticRecords.GetAnesthProvType() or AnesthLocations.IsProvider(). The way you can fix this is by changing these methods to take in a list of providers, and call those methods before the for loop.
Chris McGehee
Open Dental Software
http://www.opendental.com

User avatar
wjstarck
Posts: 935
Joined: Tue Jul 31, 2007 7:18 am
Location: Keller, TX
Contact:

Re: Long load time Middle Tier

Post by wjstarck » Mon Dec 16, 2019 4:53 pm

Makes sense.

Thanks Chris
Cheers,

Bill Starck, DDS
Big Idea Software, LLC
Developer, EASy(Electronic Anesthesia System) for Open Dental
817-807-1709
TX, USA

Post Reply