My current site is set up to leave messages for certain people the first time anyone logs into the app. The number of messages left could be anywhere from 1000 to 10000, with each being a query, and all queries in a transaction statement.
Yes, I know this seems like poor design, that is not my question.
Currently, when a user logs in, the server has to complete all of the queries before the user can actually do anything. What I mean is, the user views the login screen until the timeout kicks in and resets the page. Recently we've had waits up to 30 minutes (!)
I want to put this process on a thread such that the user can log into the website, do any activity s/he needs to, and view/delete their messages while not being impeded by the message deliverer.
My question is, does simply spinning off a new thread to handle this process solve the problem (i.e. allow the user to work while the deliverer leaves messages)? Also, does spinning off the thread impact the other web applications on the same server?
EDIT Based on KM's comments
Simplified schemas:
Tasks table:
TaskID StartDate EndDate PercentComplete TSK1 4/17/09 5/17/09 60 TSK2 3/19/09 3/29/09 80 TSK3 1/1/08 2/9/09 100
Assignments table:
TaskID ResourceID TSK1 111 TSK1 222 TSK2 222 TSK2 333 TSK2 444 TSK3 111 TSK3 333
Messages table schema:
Subject Receiver Sender Content Overdue Task 111 000 Task TSK1 is overdue. Overdue Task 222 000 Task TSK1 is overdue. Overdue Task 222 000 Task TSK2 is overdue. Overdue Task 333 000 Task TSK2 is overdue. Overdue Task 444 000 Task TSK2 is overdue.
So, the code will get all people assigned to an overdue task (i.e. EndDate earlier than today and != 100% complete) and leave a message for them telling them such
I think the real problem is that i am using a select query to get the people assigned to overdue tasks from the database and then using C# code to compose the messages and transactions before calling the database to insert the messages.