Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL performs better ! , but why?
first, dba_objects is a view --- and in your first statement, it is
executing full-table scans of several of view's base table, which might also
be view constructs (there are many layers of nested loops).
your second construct executes using indexes.
"Sunil" <sunil_franklin_at_hotmail.com> wrote in message
news:Besx8.20$w43.140_at_news.oracle.com...
> All,
>
> I had the following query which was taking ages to run :-
> <
> select s.owner || '.' || s.synonym_name,
> from dba_objects o, dba_synonyms s
> where s.owner in ('SYSTEM', 'PUBLIC')
> and o.object_type in ('TABLE', 'VIEW')
> and s.table_owner = o.owner
> and s.table_name = o.object_name
> >
>
> I changed it to the following and it was performing much better.
> <
> select s.owner || '.' || s.synonym_name
> from dba_synonyms s
> where exists ( select 'x' from dba_objects o
> where s.table_name = o.object_name
> and s.table_owner = o.owner
> and o.object_type in ('TABLE', 'VIEW')
> )
> and s.owner in ('SYSTEM', 'PUBLIC')
> >
>
> Is this way of rewriting the query ok? and can some expert out there
> explain why the second query is performing much faster. ( I am running on
> Oracle 9i ).
>
>
>
> Thanks,
> Sunil.
>
>
>
Received on Wed Apr 24 2002 - 16:35:48 CDT