homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Little help needed optimizing DB usage
for site with heavy traffic

10+ Year Member

Msg#: 3724990 posted 5:18 pm on Aug 17, 2008 (gmt 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!



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

Msg#: 3724990 posted 4:21 pm on Aug 18, 2008 (gmt 0)

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?

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved