如何确定慢查询?(how to determine slow queries?)

编程入门 行业动态 更新时间:2024-10-28 04:25:42
如何确定慢查询?(how to determine slow queries?)

我的网站正在经历一个非常缓慢的加载时间。 我怀疑它可能是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.

更多推荐

本文发布于:2023-07-29 20:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1319462.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:determine   slow   queries

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!