Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Does IN perform a implicit distinct ?
Hi All
I was wondering if anybody knew if 'IN' performs a implicit distinct? For instance say if i had the query below:
select stat from orders where account_id in (select distinct account_id from accounts)
Do i need to perform a distinct lookup of the account_id ??? Is this just a duplicate - which would require an additional sort?
I have constructed a benchmark with the same value repeated in the IN caluse and I see no difference in response time / CPU time
Test 1
select count(*) from accounts where account_id in ('15')
Test 2
select count(*) from accounts where account_id in
('15','15','15','15','15')
Test 3
select count(*) from accounts where account_id in
('15','15','15','15','15','15','15','15','15','15')
Test 4
select count(*) from accounts where account_id in
('15','15','15','15','15','15','15','15','15','15',
'15','15','15','15','15','15','15','15','15','15',
'15','15','15','15','15','15','15','15','15','15',
'15','15','15','15','15','15','15','15','15','15',
'15','15','15','15','15','15','15','15','15','15')
Bob Received on Tue May 31 2005 - 05:57:51 CDT