【问题标题】:Simple join between 3 tables takes lot of time in memsql3个表之间的简单连接在memsql中需要很多时间
【发布时间】:2015-11-30 12:03:38
【问题描述】:

我在 memsql 和 mysql 中运行了以下查询,但它所用的时间完全不同。

Memsql

select count(*) from po A , cu B , tsk C  where A.customer_id = B.customer_id and B.taskid = C.id and A.domain = 5  and week(B.post_date) = 22;
+----------+
| count(*) |
+----------+
|    98952 |
+----------+
1 row in set (19.89 sec)

Mysql

select count(*) from po A , cu B , tsk C where A.customer_id = B.customer_id and B.taskid = C.id and A.domain = 5  and week(B.post_date) = 22;
+----------+
| count(*) |
+----------+
|    98952 |
+----------+
1 row in set (0.50 sec)

为什么在 mysql 这么快的情况下 memsql 的性能那么差?

mysql 和 memsql 都在同一个 8GB 的​​四核机器上。 memsql 有 1 个主 Aggregator 节点和 3 个叶子节点。

如果有连接,memsql 性能会不会很差?

更新

Doc 可以清楚地看出,表应该在预期经常加入的列上有一个分片键。这允许优化器在查询执行期间最小化网络流量。

所以我认为我错了。我没有使用分片键,而是在表上添加了一个简单的主键。

【问题讨论】:

  • 您的表上有哪些索引?特别是,您在B.post_date 上有索引吗?

标签: sql performance time query-optimization singlestore


【解决方案1】:

您是否尝试过第二次在 MemSQL 中运行查询? MemSQL 在第一次看到查询时编译并缓存查询执行代码——MemSQL 称之为代码生成。

http://docs.memsql.com/latest/concepts/codegen/

当您再次运行查询时,您应该会看到性能显着提升。

【讨论】:

  • 如果这不起作用,请确保您在 B.customer_id、C.id 和 A.domain 上有密钥。
  • 根本没有改变@steven
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-06-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多