nbuytaert1 / apex-select2

Select lists in Oracle APEX as they should be
https://apex.oracle.com/pls/apex/f?p=64237:20
GNU General Public License v2.0
56 stars 18 forks source link

More loading time in Debug #99

Closed kinju4374 closed 5 years ago

kinju4374 commented 6 years ago

Hi, When I was testing performance improvements on my page the select2 plugin code is showing the highest time-consuming process. Can you please suggest what are the steps to solve it? I can't edit the code as its plugin code and not added by me.

rimblas commented 6 years ago

This is a pretty common issue in APEX. The best practice for performance is to grab all that code from the plugin and place it in a package. If the plugin comes with its own package I keep that. Otherwise, I create some APP_PLUGINS package and place multiple plugins in there.

The reason for the slowness is that all the PL/SQL code for the plugin needs to be hard parsed and compiled on the fly every time the plugin is referenced. This is a time-consuming activity and if you have 5 Select2 items on the page it has to happen 5 times. On the other hand, when you place the code inside a package, the code is ready to run and the code even gets cached the first time is referenced.

Unfortunately, every time you upgrade a plugin you will need to re-package its PL/SQL code.

But trust me the performance increase will be well worth it.

kinju4374 commented 6 years ago

Thanks for the response. But, how to call this plugin in APEX then? Do I need to do it dynamically?

rimblas commented 6 years ago

Here's a screenshot of what I've done in one app. All the code was bundled in a px_plugins package (px denotes my system prefix). image

As you can see I have a px_plugins.select2_render and px_plugins.select2_ajax. I did rename the calls from the plugin render and ajax respectively because my package contains code for 3 or 4 other plugins.

There's no magic here. APEX simply calls the procedures/functions specified in the fields. It looks first in the embeded plugin code, but if not it just uses the available package code.