关于mysql数据占用CPU高的问题,命令SHOW FULL COLUMNS FROM

今天为了给性能测试准备数据,信息管理提供了造数据的工具,跑起来之后,mysql的CPU直接用完,各种SQL由于执行时间都很长。

通过workbench监控,发现链接大量在执行SHOW FULL COLUMNS FROM命令。

一开始怀疑是因为使用了select * 造成的,修改代码以后,制定了每个列名,问题依旧。


后来根据JAVA进程的堆栈看到,这个命令可能是mysql的JDBC驱动程序发送的:

"Thread-12" prio=10 tid=0x0000000046a45000 nid=0x4af9 runnable [0x00000000405ba000]
   java.lang.Thread.State: RUNNABLE
   at java.net.SocketInputStream.socketRead0(Native Method)
   at java.net.SocketInputStream.read(SocketInputStream.java:129)
   at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:114)
   at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:161)
   at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:189)
   - locked <0x00002aaab686f2c8> (a com.mysql.jdbc.util.ReadAheadInputStream)
   at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3116)
   at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3570)
   at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:3559)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4110)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2570)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2731)
   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2809)
   - locked <0x00002aaab68642f0> (a com.mysql.jdbc.JDBC4Connection)
   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2758)
   at com.mysql.jdbc.StatementImpl.executeQuery(StatementImpl.java:1612)
   - locked <0x00002aaab68642f0> (a com.mysql.jdbc.JDBC4Connection)
   at com.mysql.jdbc.Field.getCollation(Field.java:493)
   - locked <0x00002aab1810c308> (a com.mysql.jdbc.Field)
   at com.mysql.jdbc.ResultSetMetaData.isCaseSensitive(ResultSetMetaData.java:567)
   at com.sun.rowset.CachedRowSetImpl.initMetaData(CachedRowSetImpl.java:704)
   at com.sun.rowset.CachedRowSetImpl.populate(CachedRowSetImpl.java:621)

下载了com.sun.rowset.CacheRowSetImple的源码:


        for (int col=1; col <= numCols; col++) {
            md.setAutoIncrement(col, rsmd.isAutoIncrement(col));
            if(rsmd.isAutoIncrement(col))
                updateOnInsert = true;
            md.setCaseSensitive(col, rsmd.isCaseSensitive(col));
            md.setCurrency(col, rsmd.isCurrency(col));
            md.setNullable(col, rsmd.isNullable(col));
            md.setSigned(col, rsmd.isSigned(col));
            md.setSearchable(col, rsmd.isSearchable(col));


只好把这里修改掉,不去掉用isCaseSensitive,直接写死了。

你可能感兴趣的:(数据存储,JAVA)