mysql - 2013 error Lost connection to MySQL server during query 错误

标签 mysql select indexing

查询 1 是

SELECT id,state,submission_id FROM document WHERE submission_id>=0;
+---------+-------+---------------+
| id      | state | submission_id |
+---------+-------+---------------+
| 3000001 |    -1 |         12345 | 
+---------+-------+---------------+
1 row in set (0.00 sec)

很明显,submission_id >=0 的记录只有一条。

查询 2 是

SELECT id,state,submission_id FROM document WHERE submission_id>=0 OR state=0 ORDER BY submission_id LIMIT 5;
ERROR 2013 (HY000): Lost connection to MySQL server during query

第三个查询是在我等了10分钟之后

SELECT * from document WHERE state=0 OR submission_id>=0 order by submission_id desc limit 5;

+----+-------+---------------+
| id | state | submission_id |
+----+-------+---------------+
|  1 |     1 |            -1 | 
|  2 |     1 |            -1 | 
|  3 |     1 |            -1 | 
|  4 |     1 |            -1 | 
|  5 |     1 |            -1 | 
+----+-------+---------------+

怎么了? id=3000001 应该是第一个吧?

这发生在我为“submission”列建立索引之后。无论如何要删除此列以使其不被索引?

引用“描述文档”的样子

+---------------+--------------+------+-----+---------+----------------+
| Field         | Type         | Null | Key | Default | Extra          |
+---------------+--------------+------+-----+---------+----------------+
| id            | int(11)      | NO   | PRI | NULL    | auto_increment | 
| state         | int(11)      | YES  | MUL | NULL    |                | 
| submission_id | int(11)      | YES  | MUL | NULL    |                | 
+---------------+--------------+------+-----+---------+----------------+

最佳答案

这里是如何删除 submission_id 索引

ALTER TABLE document DROP INDEX submission_id;

如果索引的名称不是 submission_id,您可以通过以下方式找到它:

SHOW CREATE TABLE document\G

您将在底部看到带有定义的索引的表定义。

您将看到索引的正确名称。

另一种查找 submission_id 索引名称的方法是:

SELECT index_name FROM information_schema.statistics
WHERE table_name='document'
AND column_name='submission_id';

关于mysql - 2013 error Lost connection to MySQL server during query 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8842371/

相关文章:

php - 如何使用 PHP 将多维数组存储到 mysql 中

mysql - Couchbase 基准测试显示 INSERT 和 GET 非常慢(使用 KeyValue 操作);比持久化 MySQL 数据慢

mysql - 选择 IF(查询中的查询)

sql - 多个 SQL 计入多个条件

python - iloc 和 loc 有何不同?

mysql - 将 Docker 链接到本地​​ MySQL 数据库

php - 从 mysql 列中搜索

javascript - Flask:基于先前选择的下拉值

php - 从 PHP 调用 sphinx 索引器

python - 将一行插入到索引 i 处的数据帧中