Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.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时间戳字段使SELECT查询变慢_Mysql_Mysql Workbench - Fatal编程技术网

表中的Mysql时间戳字段使SELECT查询变慢

表中的Mysql时间戳字段使SELECT查询变慢,mysql,mysql-workbench,Mysql,Mysql Workbench,我使用的Inno db表(称为test)有300k行,其中包含以下字段: id(int), sn(int), ts(timestamp), note(text), error_id(int) 索引为id、sn和ts 从测试极限01100中选择ts以0.3-0.35秒的速度进行测试, 当所有其他操作(如从测试限制0100中选择id需要0.04秒时 只有在选择*或ts时,选择才会花费大量时间。 您知道为什么会发生这种情况(ts比其他人执行选择的时间多10倍?) 实表: CREATE TABLE `

我使用的Inno db表(称为test)有300k行,其中包含以下字段:

id(int), sn(int), ts(timestamp), note(text), error_id(int)
索引为
id
sn
ts

从测试极限01100中选择ts
以0.3-0.35秒的速度进行测试,
当所有其他操作(如
从测试限制0100中选择id
需要0.04秒时

只有在选择
*
ts
时,选择才会花费大量时间。
您知道为什么会发生这种情况(ts比其他人执行选择的时间多10倍?)

实表:

CREATE TABLE `production_list_log` (<br/>
  `id` int(11) NOT NULL AUTO_INCREMENT,<br/>
  `sn` int(11) NOT NULL,<br/>
  `ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'ts - timestamp when ordercode arrived to this station\n',<br/>
  `note` text COLLATE utf8_slovenian_ci,<br/>
  `error_id` int(11) DEFAULT NULL COMMENT,<br/>
  PRIMARY KEY (`id`),<br/>
  KEY `fk_change_product_id` (`product_id`),<br/>
  KEY `sn_ts_added_kalup` (`sn`,`ts`) USING BTREE,<br/>
  CONSTRAINT `fk_change_product_id` FOREIGN KEY (`product_id`) REFERENCES `products` (`id`) ON UPDATE CASCADE<br/>
) ENGINE=InnoDB AUTO_INCREMENT=297567 DEFAULT CHARSET=utf8
创建表“生产清单日志”(
`id`int(11)非空自动增量,
`sn`int(11)不为空,
`ts`timestamp NOT NULL DEFAULT CURRENT_timestamp COMMENT'ts-订单代码到达此站点时的时间戳\n',
`注`文本校对utf8\u斯洛文尼亚语\u ci,
`错误_id`int(11)默认空注释,
主键(`id`),
键'fk\u change\u product\u id'('product\u id'),
使用BTREE键'sn\ts\u添加了'u kalup'('sn','ts'),
约束'fk\u change\u product\u id'外键('product\u id`)在更新级联上引用'product`('id`)
)ENGINE=InnoDB自动增量=297567默认字符集=utf8
我们可以查看表格信息吗?你有任何索引设置吗?你在做任何WHERE或ORDER-BY-stuff吗?除非您或服务器的互联网连接相当慢,否则您选择的字段本身不应该对速度造成太大的影响。您的问题是什么?-添加了表信息-没有,只是简单:从生产列表中选择id\u日志限制0100-问题是:为什么ts执行select的时间比db中的其他字段多10倍