Page 1 of 1

Long startup times with plugin

Posted: Wed Sep 27, 2023 2:03 pm
by wjstarck
Hello OD-

I have a customer that is seeing long load times for OD at startup.

With my plugin disabled, it's a second or two. With my plugin enabled, it's around 45-60 seconds.

Their server is a Dell PET330 with a Xeon E3-1220 @ 3 GHZ and 16 GB of RAM, Windows Server 2016.

I suspect it's the DB conversion scripts, which go all the way back to OD 7.0. There are quite a few as you might imagine :D .

Any strategies you can recommend to cut down on the load time?

Re: Long startup times with plugin

Posted: Wed Sep 27, 2023 3:40 pm
by jsalmon
Version your DB conversion scripts if they aren't already. That way the plug-in loads up in 45-60 seconds once and then subsequent times it'll see that it has already updated to the latest version and load right up.

From the 'Hints for Programmers' section:
4. If managing your own database tables, remember that the plug-in may be turned off and then turned back on a few versions later. So you can't depend on the same pref that tracks database version. You will have to store your own database version pref. If you add rows to the preference table, be sure that they are very very unique. Make sure to prefix them with a string that would be impossible for us to accidentally duplicate, as we did in the example.
https://www.opendental.com/manual/plugins.html

Re: Long startup times with plugin

Posted: Wed Sep 27, 2023 3:53 pm
by wjstarck
Hi Jason-

Thanks.

I already version my scripts like so:

Code: Select all

		public static void To_23_1_15 () {
			string command = @"ALTER TABLE anesthquickbuttons MODIFY QuickButton1 CHAR(50)";
			try {
				DataCore.GetTable(command);
			}
			catch { }
			<snip>
			To_23_1_19();

		}

		public static void To_23_1_19 () {
			string command = @"DROP TABLE IF EXISTS anesthdisplayreport";
			DataCore.NonQ(command);
			command = @"CREATE TABLE IF NOT EXISTS anesthdisplayreport (
						DisplayReportNum bigint NOT NULL auto_increment PRIMARY KEY,
						InternalName varchar(255) NOT NULL,
						ItemOrder int NOT NULL,
						Description varchar(255) NOT NULL,
						Category tinyint NOT NULL,
						IsHidden tinyint NOT NULL
						) DEFAULT CHARSET=utf8";
			DataCore.NonQ(command);
			command = @"
					INSERT INTO anesthdisplayreport(InternalName,ItemOrder,Description,Category,IsHidden) VALUES('CaseSummary',0,'Case Summary',0,0);
					INSERT INTO anesthdisplayreport(InternalName,ItemOrder,Description,Category,IsHidden) VALUES('MedsReport',1,'Meds Report',0,0);";
			DataCore.NonQ(command);
		}
	}
And I've always written the Anesthesia Plugin version to the OD Preference table since the dawn of time.

Should I be checking the Preference table and skipping those versions below the plugin version in the db?

Because I notice that it takes 45-60 sec to load everytime I launch OD. I always assumed that OD was checking the script against the running version of OD and skipping any conversions below the running version. Is this incorrect?

Re: Long startup times with plugin

Posted: Thu Sep 28, 2023 8:54 am
by jsalmon
wjstarck wrote: Wed Sep 27, 2023 3:53 pm...Should I be checking the Preference table and skipping those versions below the plugin version in the db?
Assuming your scripts do not need to be run every single time your plug-in loads / launches, yes, that's what I would do.
wjstarck wrote: Wed Sep 27, 2023 3:53 pm...I always assumed that OD was checking the script against the running version of OD and skipping any conversions below the running version. Is this incorrect?
That sounds correct in regards to our own convert script code. However, we don't do anything special for plug-in convert scripts. We don't know what they are, what they do, what they require, etc. Plug-in developers can write convert scripts to do whatever they desire. Also, users might disable your plug-in for a span of versions and we won't be the wiser. This is why it is up to you to manage your own versioning and database schemas.