Welcome to WebmasterWorld Guest from 23.20.147.6

Forum Moderators: open

Message Too Old, No Replies

Little help needed optimizing DB usage

for site with heavy traffic

     
5:18 pm on Aug 17, 2008 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 7, 2004
posts: 88
votes: 0


I've got a page where the user has different content on separate tables, such as photos, videos, messages, etc, and each time a page is viewed, a COUNT(*) query is performed on each table to get the user's content count.

The point is that I need to start avoiding DB queries because some tables are starting to crash often due to heavy access, and I'm not sure how to proceed. The 2 alternatives I handle are:

1. Reading the tables only on user login, and storing required info on $_SESSION variables
2. Creating a "user_status" table with only the user info required to show on all pages, and query it on every page shown

I'd really appreciate to hear some suggestions on which method to show, and if there's a better way to do it. As usual, thanks in advance!

4:21 pm on Aug 18, 2008 (gmt 0)

Moderator from US 

WebmasterWorld Administrator lifeinasia is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 10, 2005
posts:5664
votes: 76


I'd go with option 1. You probably want to have the queries re-run and updated whenever a user adss/deletes content as well.

I assume you have your tables indexed efficiently?

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members