How can I get a COUNT(col) ... GROUP BY to use an index?
Posted
by thecoop
on Stack Overflow
See other posts from Stack Overflow
or by thecoop
Published on 2010-04-29T11:32:14Z
Indexed on
2010/04/29
11:47 UTC
Read the original article
Hit count: 224
I've got a table (col1, col2, ...) with an index on (col1, col2, ...). The table has got millions of rows in it, and I want to run a query:
SELECT col1, COUNT(col2) WHERE col1 NOT IN (<couple of exclusions>) GROUP BY col1
Unfortunately, this is resulting in a full table scan of the table, which takes upwards of a minute. Is there any way of getting oracle to use the index on the columns to return the results much faster?
© Stack Overflow or respective owner