Home Backend Development PHP Tutorial 请问一个分表优化方案

请问一个分表优化方案

Jun 13, 2016 pm 01:52 PM
data dedecms image news

请教一个分表优化方案
系统有多个模型,每个不同模型的栏目下有多个表,例如:

新闻模型news
栏目1 对应主表为 data1_1、data1_2、.... 附加表为 fujia1_1、fujia1_2、...
栏目2 对应主表为 data2_1、data2_2、.... 附加表为 fujia2_1、fujia2_2、...


图片模型image
栏目3 对应主表为 data3_1、data3_2、.... 附加表为 fujia3_1、fujia3_2、...
栏目4 对应主表为 data4_1、data4_2、.... 附加表为 fujia4_1、fujia4_2、...

注:栏目表的主表和附加表分别以20W数据自增新表

现在假如想统计该栏目or模型本月本周或者总浏览次数之类的东西,或者随机十篇文章,如果循环该模型或者栏目多个表来排序,消耗肯定大的. 我想再建一个模型文章数据表,全放数字类型字段例如:

news模型
文章ID 栏目ID 会员ID 总浏览次数 月浏览次数 周浏览次数 ...


如果我这样做的话,调用点击前十名的文章也得两个表查10次,前面栏目分表是否多此一举? 但不这样的话,数据大放一个表中,很慢. 例如dedecms刚到10w数据,生成就卡得要死.
下了个帝国看了下他的表结构(据说他就是这样分表的),但貌似他没有多出第三个表来统计, 不知道他如何处理数据优化的呢,还没去研究。。


不知道各位前辈有什么好的建议或者意见思路吗?在此先谢了。

------解决方案--------------------
前面栏目分表是什么原则分的?
------解决方案--------------------
我首先想到的是 视图

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to use Bing Image Creator for free How to use Bing Image Creator for free Feb 27, 2024 am 11:04 AM

How to use Bing Image Creator for free

How to delete images from Xiaomi phones How to delete images from Xiaomi phones Mar 02, 2024 pm 05:34 PM

How to delete images from Xiaomi phones

Where is the imperial cms resource network template? Where is the imperial cms resource network template? Apr 17, 2024 am 10:00 AM

Where is the imperial cms resource network template?

How to use dedecms How to use dedecms Apr 16, 2024 pm 12:15 PM

How to use dedecms

Imagemagic installation Centos and Image installation tutorial Imagemagic installation Centos and Image installation tutorial Feb 12, 2024 pm 05:27 PM

Imagemagic installation Centos and Image installation tutorial

Accurate and reliable dedecms conversion tool evaluation report Accurate and reliable dedecms conversion tool evaluation report Mar 12, 2024 pm 07:03 PM

Accurate and reliable dedecms conversion tool evaluation report

How to upload local videos to dedecms How to upload local videos to dedecms Apr 16, 2024 pm 12:39 PM

How to upload local videos to dedecms

How dedecms implements template replacement How dedecms implements template replacement Apr 16, 2024 pm 12:12 PM

How dedecms implements template replacement

See all articles