NHibernate +流畅的 NHibernate +甲骨文索引
我有一个包含超过 10 000 000 行的表。 在 TOAD 中,此查询运行得很好:
select /*+ INDEX(x IDX_CASHFLOW_COMPLEX)*/ *
from MYPR.CASHFLOW x
where fk_debet in (21856, 21854, 21855)
IDX_CASHFLOW_COMPLEX 是由以下脚本创建的 5 列索引:
CREATE INDEX MYPR.IDX_CASHFLOW_COMPLEX ON MYPR.CASHFLOW
(FK_DEBIT, FK_CREDIT, FK_DOCUMENT, PAYMENTDATE, FK_PAYMENTCODE)
LOGGING
TABLESPACE INDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;
类似的查询,但没有 Oracle 提示语法,运行速度明显慢!
您能否建议是否可以告诉 NHibernate 在查询中添加 Oracle 提示?
谢谢!
I have a table with more than 10 000 000 rows.
In TOAD this query works very well on it:
select /*+ INDEX(x IDX_CASHFLOW_COMPLEX)*/ *
from MYPR.CASHFLOW x
where fk_debet in (21856, 21854, 21855)
IDX_CASHFLOW_COMPLEX is index on 5 columns created by following script:
CREATE INDEX MYPR.IDX_CASHFLOW_COMPLEX ON MYPR.CASHFLOW
(FK_DEBIT, FK_CREDIT, FK_DOCUMENT, PAYMENTDATE, FK_PAYMENTCODE)
LOGGING
TABLESPACE INDX
PCTFREE 10
INITRANS 2
MAXTRANS 255
STORAGE (
INITIAL 64K
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
BUFFER_POOL DEFAULT
)
NOPARALLEL;
Similar query but without Oracle hint syntax works significantly slower!
Would you please suggest is it possible to tell NHibernate to add Oracle hint in the query?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的优化器统计信息是最新的吗?如果没有,您可能会发现一旦生成它们,您根本不需要提示。
Are your optimizer statistics up to date? If not you may find that once they are generated you don't need the hint at all.
据推测,没有提示的查询没有使用索引。
在任何 sql 工具中尝试此操作:
...并发布最后一个命令的输出。我们可以用它来查看 Oracle 对结果集的预期基数做出的估计。
Presumably the query without the hint is not using the index.
Try this in any sql tool:
... and post the output of the last command. We can use that to see what estimations oracle is making of the expected cardinality of the result set.
有提示 /* +INDEX(...) */ :
无提示 /* +INDEX(...) */ :
With hint /* +INDEX(...) */ :
Without hint /* +INDEX(...) */ :