我的sql语句如下:
select uid from UserSource us where us.SourceID = '6c19a70397ed4770', 会有如下结果:
13637,14147,14270,14659,14708,14926,15117,15150,15796,16104,16217,16247,16271,17858,17877,18088,18282,18316,18438,18504,18811,19213,19499,19799,19855,19857,20110,20355,20384,20428,20537,21402,21560,21561,21562,21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,21575,21576,21577,21578,21579,21580,21581,21583,21584,21585,21586,21587,21588,21589,21590,21591,21592,21594,21595,21596,21598,21599,21600,21601,21602,21603,21606,21609,21610,21611,21612,21613,21616,21617,21618,21619,21620,21621,21622,21623,21624,21625,21626,21627,21628,21629,21631,21632,21633,21634,21635,21636,21637
一共是100个。我如果写
select * from Users where id in(13637,14147,14270,14659,14708,14926,15117,15150,15796,16104,16217,16247,16271,17858,17877,18088,18282,18316,18438,18504,18811,19213,19499,19799,19855,19857,20110,20355,20384,20428,20537,21402,21560,21561,21562,21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,21575,21576,21577,21578,21579,21580,21581,21583,21584,21585,21586,21587,21588,21589,21590,21591,21592,21594,21595,21596,21598,21599,21600,21601,21602,21603,21606,21609,21610,21611,21612,21613,21616,21617,21618,21619,21620,21621,21622,21623,21624,21625,21626,21627,21628,21629,21631,21632,21633,21634,21635,21636,21637)
那么可以正常查询但是如果我写成:select * from Users where id in(select uid from UserSource us where us.SourceID = '6c19a70397ed4770')就会一直查下去,而没有结果,而且我看CPU都99%,这是为什么呢?
select uid from UserSource us where us.SourceID = '6c19a70397ed4770', 会有如下结果:
13637,14147,14270,14659,14708,14926,15117,15150,15796,16104,16217,16247,16271,17858,17877,18088,18282,18316,18438,18504,18811,19213,19499,19799,19855,19857,20110,20355,20384,20428,20537,21402,21560,21561,21562,21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,21575,21576,21577,21578,21579,21580,21581,21583,21584,21585,21586,21587,21588,21589,21590,21591,21592,21594,21595,21596,21598,21599,21600,21601,21602,21603,21606,21609,21610,21611,21612,21613,21616,21617,21618,21619,21620,21621,21622,21623,21624,21625,21626,21627,21628,21629,21631,21632,21633,21634,21635,21636,21637
一共是100个。我如果写
select * from Users where id in(13637,14147,14270,14659,14708,14926,15117,15150,15796,16104,16217,16247,16271,17858,17877,18088,18282,18316,18438,18504,18811,19213,19499,19799,19855,19857,20110,20355,20384,20428,20537,21402,21560,21561,21562,21563,21564,21565,21566,21567,21568,21569,21570,21571,21572,21573,21574,21575,21576,21577,21578,21579,21580,21581,21583,21584,21585,21586,21587,21588,21589,21590,21591,21592,21594,21595,21596,21598,21599,21600,21601,21602,21603,21606,21609,21610,21611,21612,21613,21616,21617,21618,21619,21620,21621,21622,21623,21624,21625,21626,21627,21628,21629,21631,21632,21633,21634,21635,21636,21637)
那么可以正常查询但是如果我写成:select * from Users where id in(select uid from UserSource us where us.SourceID = '6c19a70397ed4770')就会一直查下去,而没有结果,而且我看CPU都99%,这是为什么呢?
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
5455 mysql 20 0 162m 25m 5584 S 99.7 14.1 0:47.35 mysqld
在你提交这个 select 语句的同时,或者 CPU 99%的时候进行看一下 show processlist另外再看一下
status;
| version() |
+-------------------+
| 5.0.51a-24+lenny2 |
+-------------------+