In my case, I have a custom forum shared among several users in asp.net and C#. I found the loading process pretty costly (several tables joined for different purposes). The users can modify and add new entries. But I don't want to load the object per user. Considering that the static variables - especially when editable- are not thread safe. I wonder what is the best practice to do so.
1 Answer
There is a short answer... and a very long answer to this question. The long answer can be found over on programmers.stackexchange.com the short answer is what I'll give you here.
I would recommend (very conditionally as I don't know the nature of the query) that you create a view in your database for that complicated join, the reason being that the database will cache the view for you and will update it every time the tables touched by the query are updated. This would mean that you only have to do a query for that view and not the massively complicated query you're doing now. Mind you this is a short term solution, if your user count grows this will likely cause your DB to start chewing CPU and ram.