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: