亚洲视频二区_亚洲欧洲日本天天堂在线观看_日韩一区二区在线观看_中文字幕不卡一区

公告:魔扣目錄網為廣大站長提供免費收錄網站服務,提交前請做好本站友鏈:【 網站目錄:http://www.430618.com 】, 免友鏈快審服務(50元/站),

點擊這里在線咨詢客服
新站提交
  • 網站:51998
  • 待審:31
  • 小程序:12
  • 文章:1030137
  • 會員:747

forum_post表是存儲主題和回復內容的表,是discuz系統中存儲內容最多的一個表。對于內容較多的大型站點來說,隨著這個表的逐漸增大,已經嚴重影響了站點的打開速度。Discuz!系統本身已經有了帖子分表功能,但是每次都要手動操作分表,過一段時間之后主表(forum_post)變的很大。本文介紹一種通過簡單修改數據表和系統程序的方法實現發帖回帖自動分表存儲。

執行思路:將forum_post平均分成10份,分別為pre_forum_post/pre_forum_post_1/pre_forum_post_2/…/pre_forum_post_9,每次發帖回帖之后根據帖子tid按10取余數分別存在不同的表中。

具體執行步驟:

1、后臺->全局,關閉網站。備份pre_forum_post表和pre_forum_thread表;

2、將數據庫中的pre_forum_post連續復制10次,分別命名為pre_forum_post/pre_forum_post_1/pre_forum_post_2/…/pre_forum_post_9;

3、分別執行如下sql語句

delete from pre_forum_post where tid%10!=0;

delete from pre_forum_post_1 where tid%10!=1;

delete from pre_forum_post_2 where tid%10!=2;

delete from pre_forum_post_3 where tid%10!=3;

delete from pre_forum_post_4 where tid%10!=4;

delete from pre_forum_post_5 where tid%10!=5;

delete from pre_forum_post_6 where tid%10!=6;

delete from pre_forum_post_7 where tid%10!=7;

delete from pre_forum_post_8 where tid%10!=8;

delete from pre_forum_post_9 where tid%10!=9;

4、再執行如下sql語句

update pre_forum_thread set posttableid=tid%10;

5、修改系統文件sourceclassmodelmodel_forum_thread.php(修改前記得備份)

找到代碼

$this->tid = C::t('forum_thread')->insert($newthread, true);

在這一行代碼下方加入

$posttableid=($this->tid)%10;

if($posttableid){

C::t('forum_thread')->update($this->tid, array('posttableid' =>$posttableid));

}

5、后臺,站長,帖子分表,點擊更新備注信息。

6、后臺,工具,更新緩存。

修改完成!

注意此方法修改后,所有通過discuz!的帖子發布和回復功能產生的內容都是自動分表存儲,但是要注意如果用了采集或其他插件發布帖子和回復請記得修改對應的程序。

分享到:
標簽:優化 帖子 教程 方案 站點
用戶無頭像

網友整理

注冊時間:

網站:5 個   小程序:0 個  文章:12 篇

  • 51998

    網站

  • 12

    小程序

  • 1030137

    文章

  • 747

    會員

趕快注冊賬號,推廣您的網站吧!
最新入駐小程序

數獨大挑戰2018-06-03

數獨一種數學游戲,玩家需要根據9

答題星2018-06-03

您可以通過答題星輕松地創建試卷

全階人生考試2018-06-03

各種考試題,題庫,初中,高中,大學四六

運動步數有氧達人2018-06-03

記錄運動步數,積累氧氣值。還可偷

每日養生app2018-06-03

每日養生,天天健康

體育訓練成績評定2018-06-03

通用課目體育訓練成績評定