|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
You eat, breathe and sleep innovation. Build your mobile intelligence with BlackBerry® experts this July. Register Today! |
|
#1
|
||||
|
||||
|
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.
|
|
#2
|
|||
|
|||
|
RE: Speeding up forum
We would need to see the table structure (including any indexes) and the queries you are using...
|
|
#3
|
||||
|
||||
|
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. |
|
#4
|
|||
|
|||
|
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....
|
|
#5
|
||||
|
||||
|
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.
|
|
#6
|
|||
|
|||
|
RE: Speeding up forum
not really...I just care what columns the where clauses of the queries use....
|
|
#7
|
||||
|
||||
|
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. |
|
#8
|
|||
|
|||
|
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 |
|
#9
|
||||
|
||||
|
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 |
|
#10
|
|||
|
|||
|
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
|
|
#11
|
||||
|
||||
|
RE: Speeding up forum
OK done. Thanks for all your help matt.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Speeding up forum |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|