[coldbox-4.1.0][cborm-1.0.3.00006] Disable event handling for specific entities?

22 views
Skip to first unread message

Nick

unread,
Nov 3, 2015, 8:22:44 PM11/3/15
to ColdBox Platform
Is it possible to disable or bypass the event handler for specific entities that don't need to be injected with anything by Wirebox?

I have an entity that's frequently being loaded in bulk (1000+) and it's very slow with eventHandling turned on - it takes about 6-7 seconds to load 2000 objects, each and every time. With eventHandling turned off it only takes less than 2.5 seconds on the first load, but it quickly reduces to less than 100ms on subsequent loads.


Jon Clausen

unread,
Nov 3, 2015, 8:54:14 PM11/3/15
to col...@googlegroups.com

Nick,

In your handler, just add that method in to this configuration in your handler:

this.aroundhandler_except = "myAction"

That will exempt that method from the aroundHandler() actions: http://coldbox.ortusbooks.com/content/event_handlers/handler_interception_methods.html . If you have preHandler and postHandler methods you can also use this.prehandler_except and this.posthandler_except as well.

If you are running in to this in development, you may want to trying the framework in production mode before you exempt the method, though. There will be a significant increase in performance once you let Coldbox “go live”. 

HTH, 

Jon


On November 3, 2015 at 8:22:47 PM, Nick (ni...@devx.co.nz) wrote:

Is it possible to disable or bypass the event handler for specific entities that don't need to be injected with anything by Wirebox?

I have an entity that's frequently being loaded in bulk (1000+) and it's very slow with eventHandling turned on - it takes about 6-7 seconds to load 2000 objects, each and every time. With eventHandling turned off it only takes less than 2.5 seconds on the first load, but it quickly reduces to less than 100ms on subsequent loads.


--
--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/coldbox/90cb9c96-3b79-4c5a-9506-fc7c688c5f67%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nick

unread,
Nov 3, 2015, 9:07:44 PM11/3/15
to ColdBox Platform
Thanks Jon for your reply, but as far as I can tell what you've suggested is for normal CB event handlers. What I'm looking for is exemption for *ORM* event handling for specific entities.

Jon Clausen

unread,
Nov 3, 2015, 9:24:39 PM11/3/15
to col...@googlegroups.com
Sorry, Nick.  I missed the [cborm…] in the subject line. How are you loading the objects?  There’s no way, that I know of, to turn off event handling temporarily, other than turning it off at the application level.  There may be ways you can speed up the loading of the objects, themselves, though, specifically in tweaking the lazy loading settings and using batchsize attributes on one-to-many and many-to-many relationships.

If you can post a code sample of how you’re loading, it might help to suggest ways to improve the performance with event handling on.
--

--
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
For News, visit http://blog.coldbox.org
For Documentation, visit http://wiki.coldbox.org
For Bug Reports, visit https://ortussolutions.atlassian.net/browse/COLDBOX
---
You received this message because you are subscribed to the Google Groups "ColdBox Platform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to coldbox+u...@googlegroups.com.
To post to this group, send email to col...@googlegroups.com.

Jon Clausen

unread,
Nov 3, 2015, 9:50:52 PM11/3/15
to col...@googlegroups.com

One other note: one way to bypass event handling somewhat is to use a criteria query in lieu of loading the objects through their ORM mappings. When dealing with large recordsets, criteria queries are much, much faster and allow more optimization.

e.g:

var criteria = getModel("Friends").newCriteria();
criteria.add(
 criteria.restrictions.isEq("Person",getModel("Person").get(id))
 );
var friends = criteria.list();

is exponentionally faster, the larger the relationship set, than:

var friends = getModel("Person").get(id).getFriends();

HTH,

Jon

br...@bradwood.com

unread,
Nov 3, 2015, 10:24:08 PM11/3/15
to col...@googlegroups.com
If you are dealing with thousands of records, I would recommend using a query instead of an array of objects.  IF you must have objects, can you pull some stack traces and see which code is taking the longest?

Thanks!

~Brad

ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: br...@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com 
 
 
--------- Original Message ---------

Nick

unread,
Nov 4, 2015, 7:19:21 PM11/4/15
to ColdBox Platform
Thanks Jon and Brad for your suggestions. I've decided to "unwire" my entities and disable eventHandling completely for now, until I have time to figure out a better solution.
Reply all
Reply to author
Forward
0 new messages