api route performance
Unanswered
Cinnamon posted this in #help-forum
CinnamonOP
wanna know the best way to optmize this route
its currenlty taking about 3 sec in avg just to do these basic things i will have to add batch upload thing in here so that would take some time obv but rn as of this its taking so much time to compile
its currenlty taking about 3 sec in avg just to do these basic things i will have to add batch upload thing in here so that would take some time obv but rn as of this its taking so much time to compile
3 Replies
Snow Goose
The biggest bottleneck is probably not the transformation itself, but doing everything synchronously inside one API request, plus repeated logging and repeated mapping loops. I would first clean the route, precompute the mapping rules, select only required DB fields, and then move the bulk contact processing into a background job with chunked inserts. That will make the import scalable and avoid timeout problems when batch upload is added.
are you in dev mode or production? like if in dev things are generally slowe as different priorities
also yeah depending on where your database is, you have quite the sum of round trips