惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Cloudbric
Cloudbric
I
InfoQ
V
V2EX
博客园_首页
The Register - Security
The Register - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
S
Secure Thoughts
Vercel News
Vercel News
Forbes - Security
Forbes - Security
云风的 BLOG
云风的 BLOG
PCI Perspectives
PCI Perspectives
L
LINUX DO - 最新话题
D
DataBreaches.Net
H
Hacker News: Front Page
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
A
About on SuperTechFans
N
News and Events Feed by Topic
Apple Machine Learning Research
Apple Machine Learning Research
Help Net Security
Help Net Security
Attack and Defense Labs
Attack and Defense Labs
N
Netflix TechBlog - Medium
Spread Privacy
Spread Privacy
F
Full Disclosure
Recorded Future
Recorded Future
AWS News Blog
AWS News Blog
博客园 - 【当耐特】
The Cloudflare Blog
T
Threatpost
T
Tor Project blog
Google DeepMind News
Google DeepMind News
C
CXSECURITY Database RSS Feed - CXSecurity.com
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Recent Announcements
Recent Announcements
M
MIT News - Artificial intelligence
A
Arctic Wolf
C
Check Point Blog
Stack Overflow Blog
Stack Overflow Blog
T
Threat Research - Cisco Blogs
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News - Newest:
Hacker News - Newest: "LLM"
WordPress大学
WordPress大学
Cyberwarzone
Cyberwarzone
小众软件
小众软件
C
Cyber Attacks, Cyber Crime and Cyber Security
P
Proofpoint News Feed
Security Latest
Security Latest
The Last Watchdog
The Last Watchdog

云心怀鹤

于日常处 · 七月记 - 云心怀鹤 腾讯云API接口自动快照教程 - 云心怀鹤 从2022年建站至今,一次莫名其妙的CC攻击 - 云心怀鹤 五一游记:走理小路,逛三星堆 - 云心怀鹤 bluehe.cn bluehe.cn 2026 春节叙事 - 云心怀鹤 盛世修典:广西美术馆特展 - 云心怀鹤 青秀山黄花风铃木:属于南宁绿城三月独有的浪漫 - 云心怀鹤 OpenClaw龙虾:Linux部署与QQBot对接体验 - 云心怀鹤 城市散步志:年前 - 云心怀鹤 乌托邦咖啡 南宁视角:灵龟山的落羽杉红了 千问ai的生态服务融合 竖图风景:从闲逛到成片
Typecho优化: Mysql添加索引提高查询速度 - 云心怀鹤
云心怀鹤 · 2026-03-27 · via 云心怀鹤


叙述1109 阅29 评

我使用的数据库是mysql5.7版本,typecho创建后可以通过以下sql语句执行达到提高查询效果,执行前需快照或者备份数据库以防重要数据丢失!还有nginx与php都可以继续优化,目前我的站点除了CDN字体加载有延迟完,几乎秒开。

屏幕截图2026-03-27

1、内容表添加复合索引

ALTER TABLE `typecho_contents`  ADD INDEX `idx_type_status_created` (`type`, `status`, `created`);

2、删除默认的created 单列索引

ALTER TABLE `typecho_contents` DROP INDEX `created`;

3、评论表添加复合索引

ALTER TABLE `typecho_comments`  ADD INDEX `idx_cid_status_created` (`cid`, `status`, `created`);

4、删除单列索引

ALTER TABLE `typecho_comments` DROP INDEX `cid`;
ALTER TABLE `typecho_comments` DROP INDEX `created`;

5、用于文章与分类的关联查询

ALTER TABLE `typecho_relationships` ADD INDEX `idx_mid_cid` (`mid`, `cid`);

6、用于分类/标签的排序显示

ALTER TABLE `typecho_metas`  ADD INDEX `idx_type_order` (`type`, `order`);

完成以上三个步骤,大部分都覆盖了。

-- 查看的索引
SHOW INDEX FROM `typecho_contents`;

SHOW INDEX FROM `typecho_comments`;

SHOW INDEX FROM `typecho_relationships`;
SHOW INDEX FROM `typecho_metas`;

最后可以查看索引使用频率,看是否生效成功,总结:一个简单的联合索引就能提高很多很多速度,在我的工作中也是如此,若查询得慢,就会使用这样子的方法。

SELECT * FROM sys.schema_index_statistics 
WHERE table_schema = '数据库名称'
  AND table_name LIKE 'typecho_%'
ORDER BY rows_selected DESC;

查询出索引的索引情况,还可以把检测结果给ai,让他进一步提出优化意见。

OPTIMIZE TABLE `typecho_contents`;
OPTIMIZE TABLE `typecho_comments`;

还可以执行上面的命令,每月一次的表优化,恭喜你,完成了Typecho数据库的核心优化。