mysqlページングクエリエラーの報告と解決
3806 ワード
mysqlページングクエリーエラー:前提:1.1ページあたり1000個のデータ2.57ページを調べたところ、次のエラーメッセージが間違っていました.
このエラーについては、ネット上では利用可能な記録がほとんどなく、最初からページが深すぎてメモリがいっぱいになったと推測していましたが、結局メモリのソートで、最後に会社の同僚に確認しました.
解決策はsqlを最適化し、深さのページングを避けることです.
まとめ:すべての最適化の根本的な目的は、使い捨てのビッグデータ量のページングを避けるためです.
org.springframework.jdbc.UncategorizedSQLException:
### Error querying database. Cause: java.sql.SQLException:
... ...
received message larger than max (18441058 vs. 16777216)
### The error may exist in sqlmap/RxOrder.xml
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### SQL: SELECT ... ... LIMIT ?,?
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:71)
...
このエラーについては、ネット上では利用可能な記録がほとんどなく、最初からページが深すぎてメモリがいっぱいになったと推測していましたが、結局メモリのソートで、最後に会社の同僚に確認しました.
解決策はsqlを最適化し、深さのページングを避けることです.
sql:
select * from table01 where id > 1000000000000 and id < 9000000000000
limit 57000,1000
sql , , ,
1( ):
select id from table01 where id > 1000000000000 and id < 9000000000000
limit 56999,1
, 56999 id
select * from table01 where id > #{id} and id < 9000000000000
limit 57000,1000
, id 1000
2( ):
select id from table01 where
id > (select id from table01 where id > 1000000000000 and id < 9000000000000
limit 56999,1)
and id < 9000000000000
limit 1000
1 , sql , , , ,
3( , ):
select id from table01 where id > 1000000000000 and id < 9000000000000
limit 57000,1000
id list, , id ,
,
, ,
4( ):
, , ,
, , ,
まとめ:すべての最適化の根本的な目的は、使い捨てのビッグデータ量のページングを避けるためです.