简体   繁体   English

是什么引起本地mysql服务器查询速度的随机峰值?

[英]what is causing random spikes in local mysql server query speeds?

So while playing around on my localhost in phpMyAdmin and doing some stuff with SQL, I realized that I would randomly get huge spikes in the time it took to perform a database query. 因此,当我在phpMyAdmin的本地主机上玩耍并使用SQL做一些事情时,我意识到,执行数据库查询所需的时间会随机增加。 I have a database table with about 3000 entries, and I was running a very simple query to display the first 2500 of them. 我有一个包含约3000个条目的数据库表,并且我正在运行一个非常简单的查询以显示其中的前2500个条目。

On average, running this query was taking around 0.003 to 0.004 seconds. 平均而言,运行此查询大约需要0.003到0.004秒。 (Of course, loading the phpMyAdmin page took much longer, but we're just looking at the query times.) However, I noticed that occasionally the query times would go up past 0.01. (当然,加载phpMyAdmin页面花费的时间更长,但是我们只是在查询查询时间。)但是,我注意到查询时间有时会超过0.01。 Once it even shot up to 0.04. 一旦达到甚至达到0.04。 So, my curiosity getting the better of me, I decided to repeatedly run the same query, and produced a graph of my results: 因此,出于好奇,我变得更好了,我决定重复运行相同的查询,并生成一个结果图:

在此处输入图片说明

I'm not running anything else on my computer that may be interacting with MySQL, and because it's my localhost I'm the only one that's doing anything to mess with my database (right?). 我没有在计算机上运行任何其他可能与MySQL交互的东西,并且因为它是我的本地主机,所以我是唯一正在做任何事情弄乱数据库的人(对吗?)。 Slight outliers are understandable, but what's causing the load times to go up anywhere from 3 to 30 times, completely randomly it seems? 稍微离群值是可以理解的,但是是什么导致加载时间增加3到30倍,看起来完全是随机的呢?

Can anyone help me satiate my curiosity? 谁能帮助我满足我的好奇心?

I'm not running anything else on my computer that may be interacting with MySQL 我没有在计算机上运行任何其他可能与MySQL交互的内容

But is there anything else running on your computer that might be interacting with your hard drive /CPU on a regular basis? 但是,您的计算机上是否还存在其他定期与硬盘驱动器/ CPU交互的东西? Because that would explain the spikes. 因为那可以解释峰值。 Maybe have a scan of running processes, and compare the cpu/disk activity against the spikes. 也许要扫描正在运行的进程,然后将CPU /磁盘活动与峰值进行比较。

Even though your database is running on your local host, it's not running in complete isolation. 即使您的数据库在本地主机上运行,​​也不是完全隔离地运行。 It is competing for your system's resources with every other process you have running. 它正在与您运行的所有其他进程争夺系统资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM