背景:数据结构
solr 4.* 或者 solr 5.1xml
数据结构存在entity嵌套字符串
问题描述:源码
全量导入100万条数据的话,子entity的query语句会被调用100万次,因为solr没有使用PreparedStatement(绑定变量的方式),SQL会在DB Server上硬解析100万次。it
此问题是solr的bug(solr-1262),从3.*到目前(5.1.0)一直没有修改。table
解决方法:变量
修改solr的源码,改成使用PreparedStatement(绑定变量的方式)。select
偷懒的方式能够hack一下solr的代码,好比hack
一、将query的格式改成 "select * from tableA where id=?###123"。bug
二、在JDBCDataSource中将Statement修改成PreparedStatement,并自行解析query中的字符串,其中真正的SQL为select * from tableA where id=?,参数为123。
更完备的方法能够修改db-data-config.xml的schema,增长支持PreparedStatement的属性~