Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: How to get query to use an index

Re: How to get query to use an index

From: Tim Gorman <tim_at_evdbt.com>
Date: Wed, 12 Apr 2006 13:04:29 -0600
Message-ID: <C062AB5D.35184%tim@evdbt.com>


Michael,

Very interesting! Expanding your test to include just using plain UNION operator (which performs a DISTINCT), the results become correct.

So, I had always thought UNION-ALL was equivalent to an OR'd expression; is it really UNION?

Thanks!!!

-Tim

on 4/12/06 12:25 AM, Michael Garfield Sørensen, CeDeT at mgs_at_CeDeT.dk wrote:

> SQL> create table mgsx(c1 varchar2(10),c2 varchar2(10));
>
> Tabel er oprettet.
>
> SQL> insert into mgsx values('x','y');
>
> 1 række er oprettet.
>
> SQL> insert into mgsx values('x','x');
>
> 1 række er oprettet.
>
> SQL> insert into mgsx values('y','x');
>
> 1 række er oprettet.
>
> SQL> select * from mgsx where c1 like 'x%' or c2 like 'x%';
>
> C1 C2
> ---------- ----------
> x y
> x x
> y x
>
> SQL> select * from mgsx where c1 like 'x%'
> 2 union all
> 3 select * from mgsx where c2 like 'x%';

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Apr 12 2006 - 14:04:29 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US