I have an application that inserts events and event relations in an org's database and has a loading icon to prevent the user from doing anything until the event and relations are properly created and inserted.

However, the first event someone makes after going to the application can take a while (5-10 seconds). Then, they go quite quickly after that first one.

Looking at the timeline in the developer console of the create method that is being triggered, 79% of the 5 seconds (which is how long it took this last time I tried it) was spent in the Database, not my actual code. So it seems it was the inserts that were hanging things up.

Is there some way to speed that up? Would triggers that orgs have be included in 'database time'?

Here is a picture of what I mean from the timeline analysis:

enter image description here

  • When you say "go quickly after the first one" do you mean that you insert one at a time, and the first one takes five seconds and all subsequent inserts (also one at a time) go faster? – DavidSchach Jan 22 '18 at 19:50
  • Yeah, The user creates an event, takes 5-10 seconds, it's created and the page is done loading. The user creates another event, takes a second. Looking at the timeline, it says 'Event Insert' 4,500ish ms. – Tyler Dahle Jan 22 '18 at 19:51
  • Please post your code - both visualforce and controller, or the various lightning component parts. Also, if you have information on schema such as security settings and other pertinent info, please provide them. – DavidSchach Jan 22 '18 at 20:02
  • Why would controller and visualforce code be necessary? Database time is not apex or visualforce code time. My code in either of those is not doing anything while it is inserting a record into the Database. And for Schema security settings... not entirely sure what you are looking for there. My user has complete read, write, access, delete permissions on events and event relations. – Tyler Dahle Jan 22 '18 at 20:05
  • Because at first glance, there is no reason why anything would be the matter, so I'm expanding the considerations. Is this happening in Production and Sandbox? Developer org? Does it happen when you insert a record via the API/Data Loader? Anonymous Apex? – DavidSchach Jan 22 '18 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.