Re: hOW EFFICINT ARE THREADS for sending mails??
Posted By:
Simon_Ablett
Posted On:
Wednesday, April 10, 2002 07:52 AM
First off, do you have a timing issue? i.e. is your daemon not performing its actions fast enough. Trying to improve the speed of an operation that doesn't need improving is a waste of energy.
Secondly, as I understand it, your operations are as follows.
1. query index table for message id
2. retrieve record from master table using the retrieved message id as key
3. create email using data from record
4. send email
5. delete record from index table
Your latency is likely to lie in the database access. You could have a thread monitoring the index table and copying new rows into a data structure in memory (this thread should also be responsible for deleting rows in order to minimise the chances of locking problems). Another thread would then use this structure to query the master table and a third could generate and send emails. But, quite honestly, I doubt that you'd see any speed improvement unless you're processing a real high volume of messages. In fact I should think it would cause more problems than it would solve (synchronisation, database locking etc). I'd be highly sceptical of your obtaining 5 times improvements - in my opinion anyone stating that is being a little naive but I stand to be corrected!!
Regards.