donglian4464 2014-10-06 19:42
浏览 85
已采纳

在MySQL中执行查询的性能。 也许是在使用缓存?

I have a MySQL server 5.5 installed on an Ubuntu Server 14.04 x64 with 12GB of RAM and a partition of 8GB for swap.

I also have a Python (django) app with a while true that is querying a table with more than 50 million rows. The query is complex with four or five INNER JOIN -one of them to a subquery-, but it takes less than a second to be completed.

At the same time, I have an other complex query to the same table to be used in PHP (mysqli). The query is executed every 10 second through ajax (127.0.0.1).

I experienced the following scernario:

  • If the python script is stopped, the PHP is doing the query very fast (0~10ms)
  • If the python script is running, the first time the query of PHP is executed it takes a lot of time (~30s), but next times it does the job very fast (0~10ms)

In order to dismiss any problem related to the network, I tried the same scenario but using Toad software instead of PHP: The problem was the same.

Could be the MySQL cache? How could I discard it?

Thank you very much.

  • 写回答

1条回答 默认 最新

  • dongmubi4444 2015-06-30 18:39
    关注

    Adding an index solved the issue.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元