休眠 - 打开和关闭SQL索引使用 [英] Hibernate - turning on and off SQL Index usage

查看:171
本文介绍了休眠 - 打开和关闭SQL索引使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何明确地告诉Hibernate使用或不使用SQL索引?

Hibernate是否创建SQL索引,如果它发现它会有效地利用资源? 解决方案


 如何显式地告诉Hibernate使用或不使用SQL索引


强制执行全表扫描的最简单方法是删除索引。为什么要维护一个你不想使用的索引。

Hibernate是一个ORM工具,它是决定如何执行查询的底层数据库,无论是否使用索引。因此,如果你想保留索引,并且你认为查询平面器在不应该的时候选择索引,那么也许你可以扭转SQL查询,以便它产生全表扫描,或者使用特定于数据库的SQL语法 - Oracle中的SELECT FULL()... ,Postgresql中的 enable_indexscan(false)等等(如果存在这种情况为你的分贝)。


Hibernate创建SQL索引如果它发现它会有效使用
资源

没有。

How can I explicitly tell Hibernate to use or not to use SQL index?

Also does Hibernate create SQL index if it finds it would be efficient use of resources?

解决方案

How can I explicitly tell Hibernate to use or not to use SQL index

The easiest way to force a full table scan is to drop the index. Why maintaining an index you don't want to use anyway.

Hibernate is an ORM tool, it's the underlaying database that decides how to execute queries - whether or not to use an index. So if you want to keep the index, and you think the query planer picks the index when it shouldn't, then maybe you could twist the sql query so that it results in a full table scan, or use a database specific sql syntax - SELECT FULL()... in Oracle, enable_indexscan(false) in Postgresql, etc, (if such thing exists for your db).

does Hibernate create SQL index if it finds it would be efficient use of resources

No.

这篇关于休眠 - 打开和关闭SQL索引使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆