【发布时间】:2014-11-17 14:29:54
【问题描述】:
我在运行此查询时遇到问题:
select * from logs l
where l.id in(select max(id)
from logs
group by usuario_id);
关于这个结构:
+-----------------+--------------+------+-----+-------------------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+-------------------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| usuario_id | int(11) | YES | MUL | NULL | |
| projeto_id | int(11) | YES | MUL | NULL | |
| title | varchar(500) | YES | | NULL | |
+-----------------+--------------+------+-----+-------------------+----------------+
我已尝试在 3 个不同的服务器上运行此查询:
mysql> show variables like "%version%";
+-------------------------+-------------------------+
| Variable_name | Value |
+-------------------------+-------------------------+
| innodb_version | 5.5.40 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.40-0ubuntu0.12.04.1 |
| version_comment | (Ubuntu) |
| version_compile_machine | x86_64 |
| version_compile_os | debian-linux-gnu |
+-------------------------+-------------------------+
哪台是我的个人电脑,另一台是 2 台:
+-------------------------+-------------------------+
| Variable_name | Value |
+-------------------------+-------------------------+
| innodb_version | 5.5.40 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.40-0ubuntu0.14.04.1 |
| version_comment | (Ubuntu) |
| version_compile_machine | x86_64 |
| version_compile_os | debian-linux-gnu |
+-------------------------+-------------------------+
托管在 digitalocean 和亚马逊上。
在这些系统上,mysql 进程在发送此查询时保持 100% 运行,并且仅在手动停止查询时才停止...
奇怪的是,这个查询在 windows 上运行没有任何问题(使用 wampp mysql)
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 5.6.12 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.6.12-log |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86_64 |
| version_compile_os | Win64 |
+-------------------------+------------------------------+
这是 MySQL 版本的问题还是操作系统的问题?
【问题讨论】:
标签: mysql linux windows subquery deadlock