Jump to content

Which is more efficient for a forum?


LanceT

Recommended Posts

Having little knowledge of efficiency, I was wondering which would be more efficient for counting a user's number of posts for a forum.

 

Option 1

Selecting the total number of posts and topics that the user has made

 

Option 2

Having a user field that keeps track of the number of posts and topics, which is incremented / decreased every time a post is made or deleted.

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/48051-which-is-more-efficient-for-a-forum/
Share on other sites

Creating the proper indexes on the table will yield negligible performance increases in storing the users posts in a field. Not to mention, it's a PITA to have to keep updating the number of posts a user has using method 2.

 

My recommendation is option1.

I must agree with KeeB, hands down option 1.

 

A smart database will cache your query and it will only be costly the first time the query is called. In addition, you can set the field in a session. The cost should be negligable.

 

Do not try to optimize the database with fancy tricks unless you know it will have a significant performance gain. Let the database do what it is intended to do. Optimize only if needed....

 

 

A smart database will cache your query and it will only be costly the first time the query is called. In addition, you can set the field in a session. The cost should be negligable.

 

 

Don't really know how to cache queries, does mysql do this automatically or do I have to setup something different?

 

Please help!

 

 

A smart database will cache your query and it will only be costly the first time the query is called. In addition, you can set the field in a session. The cost should be negligable.

 

 

Don't really know how to cache queries, does mysql do this automatically or do I have to setup something different?

 

Please help!

 

I'm not as familiar with MySQL/PHP, but most databases I encounter, can do stored procedures. In some languages you can also specify to cache the query, for ColdFusion that is with cachedwithin attribute and for Java/JSP you can use PreparedStatements.

 

Perhaps, somebody else can shed some light on how to do this in PHP/MySQL. I'm sure they have an equivalent or do some Google searches.

 

Hope this helps...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.