Oracle Internals
JulianDyke.com

Welcome

Consultancy

Seminars

Blog

Presentations

Diagnostics

Internals

 

HASH (GROUP BY)

Description

Provides a more efficient implementation of the sort algorithm for GROUP BY statements

Versions

This operation is implemented in the following versions

10.2.0

This operation replaces the SORT(GROUP BY) operation in limited circumstances

Example

This example was developed using Oracle 10.2.0.1 on Linux

This example requires the following table definitions

    CREATE TABLE t1 (c1 NUMBER);

The statement

    SELECT c1,COUNT(*) FROM t1
    GROUP BY c1;

generates the following execution plan

0     SELECT STATEMENT Optimizer=CHOOSE
1   0   HASH (GROUP BY)
2   1     TABLE ACCESS (FULL) OF 'T1'

If the "_gby_hash_aggregation_enabled" parameter is set to FALSE (default TRUE) then the HASH (GROUP BY) operation is disabled. For example

    ALTER SESSION SET "_gby_hash_aggregation_enabled" = FALSE;

Now the statement

    SELECT c1,COUNT(*) FROM t1
    GROUP BY c1;

generates the following execution plan

0     SELECT STATEMENT Optimizer=CHOOSE
1   0   SORT (GROUP BY)
2   1     TABLE ACCESS (FULL) OF 'T1'