Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: DISTINCT as a way to slow down queries
On 3 Oct 2005 12:10:50 -0700, "cumin" <jkilbourne_at_gmail.com> wrote:
>I just ran a query, SELECT blah blah, and had to hit Ctrl-C as the
>results flew by; 6000 rows of the same two values. So I added DISTINCT
>to the front, and I am still waiting for results 10 minutes later. Why
>does DISTINCT have such a dramatic effect on performance?
DISTINCT will guarantee every row returned is unique. Consequently Oracle will perform a SORT UNIQUE operation on the *entire* resultset. You can of course tune your sort operations, but a sort is what you are going to get because of your DISTINCT.
-- Sybrand Bakker, Senior Oracle DBAReceived on Mon Oct 03 2005 - 15:22:48 CDT