Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today!
  #1  
Old June 17th, 2003, 06:22 PM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
Speeding up forum

OK. For my forum I have two tables. Forum_posts and forum_topics. Forum_topics has all the topics. The forum_posts table has all the replies to the forum_topics. For my page that displays the posts and replies i select from both these tables but in different queries. Since my site seems to be lagging a little bit, I wanted to know if there's a way to speed up my forums.

Reply With Quote
  #2  
Old June 17th, 2003, 11:42 PM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Speeding up forum

We would need to see the table structure (including any indexes) and the queries you are using...

Reply With Quote
  #3  
Old June 18th, 2003, 12:36 AM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speeding up forum

#
# Table structure for table `forum_posts`
#

CREATE TABLE forum_posts (
id int(11) NOT NULL auto_increment,
topic_id int(11) NOT NULL default '0',
board_id int(11) NOT NULL default '0',
post text NOT NULL,
username varchar(255) NOT NULL default '',
date text NOT NULL,
edit_date int(11) NOT NULL default '0',
last_update int(11) NOT NULL default '0',
PRIMARY KEY (id)
) TYPE=MyISAM;
# --------------------------------------------------------

#
# Table structure for table `forum_topics`
#

CREATE TABLE forum_topics (
id int(11) NOT NULL auto_increment,
board_id int(11) NOT NULL default '0',
subject varchar(255) NOT NULL default '',
description text NOT NULL,
post text NOT NULL,
username varchar(255) NOT NULL default '',
posts int(11) NOT NULL default '0',
date int(11) NOT NULL default '0',
edit_date int(11) NOT NULL default '0',
top_date int(11) NOT NULL default '0',
sticky text NOT NULL,
PRIMARY KEY (id)
) TYPE=MyISAM;


That's table structure
I really just wanted to know if there's a better way to store the info.

Reply With Quote
  #4  
Old June 18th, 2003, 12:56 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Speeding up forum

Looks ok...it appears that some indexes would help you though...but without seeing the queries, I can't suggest indexes....

Reply With Quote
  #5  
Old June 18th, 2003, 12:57 AM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speeding up forum

Hmmmm. I'd need to post all 200+ lines of code for the two pages that use those tables for you to be able to make any sense of them.

Reply With Quote
  #6  
Old June 18th, 2003, 01:06 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Speeding up forum

not really...I just care what columns the where clauses of the queries use....

Reply With Quote
  #7  
Old June 18th, 2003, 01:15 AM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speeding up forum

Ok here are the main queries:
select count(*) as num from forum_topics where board_id='".$board."'"
select * from forum_topics where board_id=$_GET[board] order by sticky desc, date desc limit $startat,$num
select count(*) as num from forum_posts where board_id=".$board." and topic_id=".$row[0]
select * from forum_topics where id=$_GET[id]
select * from users where id=".$row[5]

if you need more info just let me know.

Reply With Quote
  #8  
Old June 18th, 2003, 01:21 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Speeding up forum

forum_topics...place index on board_id, sticky, date (in that order)

forum_posts...place index on board_id, topic_id (in that orde

Reply With Quote
  #9  
Old June 18th, 2003, 01:51 AM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speeding up forum

OK. Sticky is a text field so the index failed:
SQL-query : [Edit]

ALTER TABLE `forum_topics` ADD INDEX(`sticky`)

MySQL said:


BLOB column 'sticky' used in key specification without a key length

Reply With Quote
  #10  
Old June 18th, 2003, 10:09 AM
Matt Matt is offline
Moderator
Codewalkers Specialist (4000 - 4499 posts)
 
Join Date: Apr 2007
Location: Florida
Posts: 4,158 Matt User rank is Private First Class (20 - 50 Reputation Level)Matt User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 h 10 m 20 sec
Reputation Power: 6
RE: Speeding up forum

what is sticky? just an indicator that it is a sticky post or not? if so, change it to a tiny int and use a 1 or a 0. also...you should be putting the index on all the columns I listed at the same time. I.e. one index on: board_id, sticky, date


Reply With Quote
  #11  
Old June 18th, 2003, 03:29 PM
sliver's Avatar
sliver sliver is online now
Moderator
Codewalkers Novice (500 - 999 posts)
 
Join Date: Apr 2007
Location: WI, USA
Posts: 888 sliver User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 21 h 17 m 29 sec
Reputation Power: 2
Send a message via AIM to sliver Send a message via XFire to sliver
RE: Speeding up forum

OK done. Thanks for all your help matt.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Speeding up forum


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway