Welcome Guest, Not a member yet? Register   Sign In
Building a Read vs Unread Status for a Forum

[quote author="AgentPhoenix" date="1257555038"]
Weird, I had the box checked to notify me of responses to the thread and it didn't.

I'm sure you'll be writing a much more considerate forum! Smile

Quote:Anyway, for the part of this that checks for unread topics within a given forum, it shouldn't be too much of an issue because you'll only ever be checking a certain number of threads anyway, right? For example, if you have 50 threads to a page, then you'll only have to check those 50 threads for unread state, not all 800,000 that exist in that forum (unless I'm not thinking of something). Of course, when checking the general read/unread state of a forum, I can see where it might get hairy.

Just so - and the same reasoning I used. 10 or perhaps 20 threads shown per page, means it's a fairly modest number of calls into the DB. Given you'd be indexing the relevant columns, and they're all integers, it should be pretty snappy.

Similarly I recall a problem that TheFuzzy0ne highlighted a while ago, viz the counting of unread messages in a forum - which I couldn't easily facilitate with my design. I had to loop (or do sub-selects) through all the threads within a forum - which is particularly expensive - and do a message count attached to those threads, totalling them all up. My response was that I didn't really care about trying to show the total number of unread (or even just a full total) messages within a forum - and I still tend to think that it's not terribly important information. I guess it depends what forum systems you're using to, and the way you interact with them. I wanted to avoid the idea of forum groups - as it would introduce a fourth layer to the architecture - but I know that some people find that design very appealing. Happily I was mostly writing my forum code a) to learn from experience, and b) for a custom 27-year coding project I'm slowly working on (ie. I'm not too fussed about how useful it would be in other environments).

In any case, what I think I'd do now is just denormalise the schema, and introduce a total_messages column in the forum table.

Hi vokic and jedd first of all thank you both for the very informative replies - especially the example of how to calculate cost.

Even with the small project i'm working on now I constantly have to explode strings, iterate through them and process them and then repeat this for the number of "listings". i just get a bit worried when I see so much looping and exploding.

The thing is there are 3000 people at my work but only 1000 of us follow the same "shifts". If i were to extend the program later to try and include the others I'm worried about the performance. I know i'm getting ahead of myself but I shudder at the thought of trying to change things at a later stage. It probably won't get to that stage but I'd like to learn best practice anyway for any possible future projects.

I'm curious to know the number of users for your forum jedd, if it's not classified.


Quote:I'm curious to know the number of users for your forum jedd, if it's not classified.

One. Smile

It's something that would be fairly easy to wrap some load testing scripts around, however - or just rattle up some test data and a script that generates a similar set of db queries.

Theme © iAndrew 2016 - Forum software by © MyBB