Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> SQLServer beats 8i finding top-10 duplicates
Background:
Given the following table:
create table testtable (num number(9));
Note: no index present.
Problem:
Insert 1 million random numbers with value from 1 to 100,000. Write a query that finds the top 10 most duplicated numbers.
Oracle 8i:
select * from (
select count(num) from testtable group by num order by count(num) desc)where rownum < 10;
Time: ~ 3 minutes
SQLServer 7:
[After creating a similar table in its syntax...]
select top 10 count(num) from testtable
group by num order by count(num)
Time: 9 seconds
Is this sort of operation just a sweet spot for SQLServer? Can I get Oracle to match SQLServer performance (adding indexes is ok, raw performance is the hope)? Any stupid mistakes in my Oracle attempt...?
Thanks for any insight anyone can offer.