Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL statement -- about index and group by
°½Ãi¿ß <Grafield_at_grafield.com.tw> wrote ...
> When I issue an Select statement with group by ,
> is it useful to create a index on the columns in group by function ?
>
> example :
>
> There is a lot of data in Table Table_AA, I use
>
> SELECT COUNT(*), C_1, C_2, C_3, C_4, C_5
> FROM TABLE_AA
> GROUP BY C_1, C_2, C_3, C_4, C_5
>
> For the performance, do I need to create a index on (C_1, C_2, C_3, C_4,
> C_5 )
I don't think an index would be beneficial for THIS statement. Since you're not restricting the range of values returned, a full table scan is needed, which would not use the indexes.
Now you need to think about other parts of your application, maybe they could benefit from indexes on the above columns. But the statement above would not.
Chris