Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Performance 如何加速hibernate标准';我喜欢查询';使用oracle数据库_Performance_Oracle_Hibernate - Fatal编程技术网

Performance 如何加速hibernate标准';我喜欢查询';使用oracle数据库

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

我们将hibernate与oracle(11)一起使用,由于使用了不区分大小写的“like”,因此存在严重的性能问题

java/hibernate代码如下所示:

 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”创建快速查询呢?

基于函数的索引将是我的选择。记住:

  • 使用基于成本的优化器。基于函数的索引仅对基于成本的优化器可见,并且永远不会被基于规则的优化器使用
文章节选