我的网站正在经历一个非常缓慢的加载时间。 我怀疑它可能是javascript或php导致更长的加载时间,但我已经在YSlow测试了我的网站,它的等级是B,我认为也不错。
现在我想检查我的数据库是否有查询错误,数据库索引导致我的网站加载速度变慢。
是否有一些教程或技巧我可能会阅读或试图测试数据库,以确定是否有慢查询? 有关数据库管理的提示吗?
My site is experiencing a really slow loading time. I have suspected that it might be javascript or php that causes longer loading time but i have tested my site in YSlow and its grade is B which i think is not bad.
Now i want to check my database if something is wrong with queries, database indexing that causes my site to load slower.
Is there some tutorials or tricks i might read or try to test database to figure out if there is slow queries? Any tips for database management?
最满意答案
为了加快查询执行速度,我总是回到2个咒语 -
索引,索引和索引。 尝试尽可能地摆脱JOINS 。有一些经过试验和测试的方法来清除慢速查询。 您需要打开慢查询日志 。 这会记录执行时间超过x秒的所有查询。 x由mysql.conf中指定。
一旦慢速查询开始登录日志。 您可以使用EXPLAIN分析每个查询,并适当添加索引以加快查询执行速度。
I always fall back to 2 mantras for faster query execution -
Indexes, indexes and indexes. Try to get rid of JOINS as much as possible.There are some tried and tested methods to weed out slow queries. You need to turn on slow query log. This logs all those queries which take more than x seconds to execute. x is specified by you in mysql.conf.
Once the slow queries start logging in the log. You can analyse each query using EXPLAIN and appropriately add indexes to speedy the query execution.
更多推荐
发布评论