Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL函数索引_Mysql_Indexing_Mysql 5.6_Sql Optimization - Fatal编程技术网

MySQL函数索引

MySQL函数索引,mysql,indexing,mysql-5.6,sql-optimization,Mysql,Indexing,Mysql 5.6,Sql Optimization,我们有一个用例,在这个用例中,我们需要近实时地复制一个大表(具有一些重DML活动-10K/秒)。以下是表结构(MySQL 5.6)—— 我们正在使用以下轮询查询- select * from table where timestamp > ? order by timestamp ASC limit 50000 (Index on timestamp column) 很快,我们开始观察复制延迟(考虑到网络延迟和查询执行开销),现在我们希望并行运行更多轮询实例。我们尝试使用基于MOD的

我们有一个用例,在这个用例中,我们需要近实时地复制一个大表(具有一些重DML活动-10K/秒)。以下是表结构(MySQL 5.6)——

我们正在使用以下轮询查询-

  select * from table where timestamp > ? order by timestamp ASC limit 50000 (Index on timestamp column)
很快,我们开始观察复制延迟(考虑到网络延迟和查询执行开销),现在我们希望并行运行更多轮询实例。我们尝试使用基于MOD的查询-MOD(production\u id,N)来拆分查询

然而,这不起作用,因为MySQL 5.6不支持基于函数的索引,并且查询之间有太多的重叠——因为优化器使用时间戳索引,然后过滤出结果集。一种可能的解决方案是创建一个基于MOD的列,然后在其上添加一个索引(MOD column+timestamp)


因为,我们的表太大了,所以迁移(添加新列和索引)可能需要很长时间。所以,我们想知道是否有其他的选择,我们可以考虑。如有任何建议,我们将不胜感激。

评论不可用于长时间讨论;此对话已结束。评论不用于扩展讨论;这段对话已经结束。
  select * from table where timestamp > ? order by timestamp ASC limit 50000 (Index on timestamp column)
  select * from table where MOD(production_id, 2) = 0 AND timestamp > ? order by timestamp ASC limit 50000;
 select * from table where MOD(production_id, 2) != 0 AND timestamp > ? order by timestamp ASC limit 50000;