Oracle HASH GROUP BY & SORT GROUP BY performance [message #308842] |
Tue, 25 March 2008 12:30 |
rkg_007
Messages: 4 Registered: March 2008
|
Junior Member |
|
|
Hi,
I have a select query which uses GROUP BY and HAVING clause performing selct over 3 million records.
In oracle 10g one version (i think rel 2), the explain plan shows HASH GROUP BY and this query runs very fast.
In oracle 10g another version (i think rel 1), the explain plan shows SORT GROUP BY and this query takes hours.
Pls suggest what should i do? Is there any hint that can make the query use HASH GROUP BY instead of SORT GROUP BY.
Or is there any other option that i should try?
Thanks in advance.
|
|
|
|
|
|
|
|
|
|
Re: Oracle HASH GROUP BY & SORT GROUP BY performance [message #308890 is a reply to message #308842] |
Tue, 25 March 2008 18:32 |
gintsp
Messages: 118 Registered: February 2007
|
Senior Member |
|
|
Yea hash group by was introduced in 10.2 however you can check why sort is too long and whether it is so because of sorts on disk. One of the easiest ways to check it is using autotrace, or you can try also v$mystat and appropriate statistic from v$statname.
If there are sorts on disk then there are two possibilities:
1) increase pga_aggregate_target if you are using workarea_size_policy = auto keeping in mind that maximum only a portion of it (~ 5%) can be used for a single session.
2) increase sort_area_size if you are using workarea_size_policy = manual. Better do that only for this particular session. In fact you can also in this session switch to workarea_size_policy = manual.
More sort space should help assuming of course this is the reason why the query is slow.
Gints Plivna
[Updated on: Wed, 26 March 2008 01:46] by Moderator Report message to a moderator
|
|
|