首页 > 解决方案 > 谷歌云sql极慢

问题描述

我正在为我的一个项目使用云 sql 实例(db-n1-standard-1 1vCPU,3.75 GB)

我注意到查询很慢

例如,对空表(SELECT * from customer)的 SELECT 查询需要0.03 秒,而在我的 Macbook Pro Retina 2013 MAMP 本地数据库上需要0.00057 秒

我的地区设置为“Europe-west1”(比利时),我在意大利。

为了测试我将云 sql db 连接到我的 macbook 上的 Mysql Workbench。

如何提高性能?所以它真的无法使用。

有关信息,数据库引擎是 InnoDB。

提前致谢!:)

标签: mysqlsqlgoogle-cloud-platformgoogle-cloud-sql

解决方案


europe-west6 (Zurich) might be faster since it's closer to you, but...I mean, it's the internet. Of course it's going to be faster by several orders of magnitude on a local machine vs. the internet. You're measuring apples to oranges, and it may be that if your application requires latency below a certain threshold, then an internet-based data store won't be a workable solution. If you require consistency across locations, then it is what it is though, and there are strategies to help with that (aggressive local cacheing, etc), but at some point, you're dealing with internet latency.

Edit: Also, if you're going to test timing, you should really evaluate connection time vs. transaction time, which will tell you more about where your latency is coming from. Doing some network evaluation on just round-trip latency from you to where the server is located (tracert and/or just ping to a known server nearby will help with this) is a good idea as well.

Barring something else going on (and we'd need more information to evaluate), my guess is that it's not Cloud SQL that's slow, it's the internet.


推荐阅读