Current implementation is query all matching AD_PInstance records then limit it after. In my case there is a problem when one user have thousands AD_PInstance records of one process causing long loading time to even load the parameter panel because it will query all the records first. It would be faster to just limit the records at query level.
Note in attached patch I construct the X rows at sql string because you can't use it as parameter. Also FETCH FIRST X ROWS ONLY is ANSI SQL but I only test it at postgresql, if someone have oracle instance installed please test it, thanks.
Current implementation is query all matching AD_PInstance records then limit it after.
In my case there is a problem when one user have thousands AD_PInstance records of one process causing long loading time to even load the parameter panel because it will query all the records first. It would be faster to just limit the records at query level.