I have a scenario where I really need to optimize the speed of updating umbraco.
Scenario...
I am sending email alerts to 100ds / 1000ds of nodes.
First I get each node awaiting an email alert
No problem I can return a list pretty quick and only hit the database once.
I then generate the email template and send out each email
No problems here. Takes a while but sending emails do.
I then update each notes LastSentDate so I know not to send them the email alert again.
This is the problem. Individually updating each node is very time consuming and at the moment takes multiple hits to the database.
I am thinking there is a better way to update all these nodes in one go. My questions are.....
Does the Umbraco API have a method which does exactly this. I am hoping I can just compile a list of nodeIds and fire this at Umbraco to update in one go.
Failing this my plan B would be to manually update all the records directly to the database. Is there a function in the Umbraco API that allows me to pass in SQL to run an update. If so what is this and is there anything I need to do after the database update to make sure the XML is inline with the database (re-publish or something)?
We have also done something sending bulk mails and the mails get a lot of content for the nodes.
We how ever created at a mail queue table. So when our trigger fires for the node we get all the data needed to send the e-mail (mailto, mailfrom, body,..) and create a record in the mail queue table.
We than have a scheduled task that reads out this database and starts sending the mails.
There seems to be multiple solutions to your problem.
You mentioned how you update each nodes 'LastSentDate', so that you know not to send another alert email.
Personally, I would remove this property completely, and instead opt to send a confirmation e-mail or provide some kind of alert which tells you that you have sent alert emails to all of the contacts.
You could include specific details about this email, it is entirely up to yourself.
Whilst this might not be entirely robust, it will certainly reduce the database hits and still inform you that all nodes have been alerted.
Alternatively, you could nest the contacts within another node which contains a 'LastSentDate' property. You could send an alert email to all of your contacts, then update this single property ONLY when all emails have been sent.
Umbraco - Update multiple node programmatically
Hi,
I have a scenario where I really need to optimize the speed of updating umbraco.
Scenario...
I am sending email alerts to 100ds / 1000ds of nodes.
First I get each node awaiting an email alert
I then generate the email template and send out each email
I then update each notes LastSentDate so I know not to send them the email alert again.
I am thinking there is a better way to update all these nodes in one go. My questions are.....
Does the Umbraco API have a method which does exactly this. I am hoping I can just compile a list of nodeIds and fire this at Umbraco to update in one go.
Failing this my plan B would be to manually update all the records directly to the database. Is there a function in the Umbraco API that allows me to pass in SQL to run an update. If so what is this and is there anything I need to do after the database update to make sure the XML is inline with the database (re-publish or something)?
Thanks
David
May I ask, why are the nodes awaiting an alert email?
Does this alert email only apply to newly generated nodes, or are these alert emails sent out frequently to all nodes?
Hi,
No this is not just for new nodes. I have a collection of contacts (nodes) which I will batch send notifications emails to.
It's not a massive problem but I would like to update all nodes as sent in one update rather than hitting the database for each node.
for example possibly passing a list of nodes into the save and publish method or something on the same lines.
contentService.SaveAndPublishWithStatus(List);
Kind Regards
David
Hi David,
What is the trigger for sending the e-mail.
We have also done something sending bulk mails and the mails get a lot of content for the nodes.
We how ever created at a mail queue table. So when our trigger fires for the node we get all the data needed to send the e-mail (mailto, mailfrom, body,..) and create a record in the mail queue table.
We than have a scheduled task that reads out this database and starts sending the mails.
Dave
There seems to be multiple solutions to your problem.
You mentioned how you update each nodes 'LastSentDate', so that you know not to send another alert email.
Personally, I would remove this property completely, and instead opt to send a confirmation e-mail or provide some kind of alert which tells you that you have sent alert emails to all of the contacts.
You could include specific details about this email, it is entirely up to yourself.
Whilst this might not be entirely robust, it will certainly reduce the database hits and still inform you that all nodes have been alerted.
Alternatively, you could nest the contacts within another node which contains a 'LastSentDate' property. You could send an alert email to all of your contacts, then update this single property ONLY when all emails have been sent.
is working on a reply...