[
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3325?page=c...
]
Seth Wilcox commented on HHH-3325:
----------------------------------
In oracle, to get maximum performance, you can explicitly tell the DB that you are doing a
pagination query(by using the select /*+ FIRST_ROWS(n) */ hint). When you do this, as
soon as oracle has the number of rows you said you needed, the DB immediately stops and
returns. Also, it can change the way the Cost based optimizer works. In my experience,
it makes a noticeable and measurable impact on performance. The hint is what is still
missing.
Pagination with Oracle ROWNUM is sub-optimal
--------------------------------------------
Key: HHH-3325
URL:
http://opensource.atlassian.com/projects/hibernate/browse/HHH-3325
Project: Hibernate Core
Issue Type: Bug
Affects Versions: 3.2.5
Reporter: e. wernli
Attachments: OracleLimit.patch, OracleLimit.patch
Pagination with Oracle ROWNUM is sub-optimal
The feature works but result in sub-optimal SQL. The generated SQL is the following:
select * from ( select row_.*, rownum rownum_ from ( select this_.id as id3_0_,
this_.version as version3_0_, this_.name as name3_0_, this_.type as type3_0_,
this_.marketstatus as marketst5_3_0_ from Customer this_ order by this_.id asc ) row_ )
where rownum_ <= ? and rownum_ > ?
But this SQL is faster:
SELECT *
FROM (SELECT row_.*, ROWNUM rownum_
FROM (SELECT this_.ID AS id3_0_, this_.VERSION AS version3_0_,
this_.NAME AS name3_0_, this_.TYPE AS type3_0_,
this_.marketstatus AS marketst5_3_0_
FROM customer this_
ORDER BY this_.ID ASC) row_
WHERE ROWNUM <= ?)
WHERE rownum_ > ?
The second solution allows Oracle to use an optimization that can dramatically reduce the
time of the query, especially one of the first page is retrieved.
See this link for an explanation of this optimization:
http://decipherinfosys.wordpress.com/2007/08/09/paging-and-countstopkey-o...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://opensource.atlassian.com/projects/hibernate/secure/Administrators....
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira