Performance 如何加速hibernate标准';我喜欢查询';使用oracle数据库
我们将hibernate与oracle(11)一起使用,由于使用了不区分大小写的“like”,因此存在严重的性能问题 java/hibernate代码如下所示:Performance 如何加速hibernate标准';我喜欢查询';使用oracle数据库,performance,oracle,hibernate,Performance,Oracle,Hibernate,我们将hibernate与oracle(11)一起使用,由于使用了不区分大小写的“like”,因此存在严重的性能问题 java/hibernate代码如下所示: c1.add( Restrictions.ilike("address", address) ); 这将导致一个sql语句,如 select * from ACCOUNT where lower(ADDRESS_1) = ? “lower”函数使oracle无法使用导致全表扫描的索引 我正在考虑在db表中引入一个新列,该列包含a
c1.add( Restrictions.ilike("address", address) );
这将导致一个sql语句,如
select * from ACCOUNT where lower(ADDRESS_1) = ?
“lower”函数使oracle无法使用导致全表扫描的索引
我正在考虑在db表中引入一个新列,该列包含address的小写内容。
然后我可以使用:
c1.add( Restrictions.ilike("addressLCase", address.toLowerCase()) );
。。。但我真的不喜欢将内容存储两次的想法
然后我考虑创建一个小写的索引
CREATE INDEX ADDRESS_1_IDX ON ACCOUNT lower( ADDRESS_1 ) ;
但这不起作用,因为我无法说服优化器使用此索引
那么,如何使用hibernate criteria API和“ilike”创建快速查询呢?基于函数的索引将是我的选择。记住:
- 使用基于成本的优化器。基于函数的索引仅对基于成本的优化器可见,并且永远不会被基于规则的优化器使用