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

Home -> Community -> Usenet -> c.d.o.server -> Re: select ... order by PK performance

Re: select ... order by PK performance

From: Lothar Armbruester <lothar.armbruester_at_t-online.de>
Date: Thu, 28 Oct 2004 18:37:01 +0200
Message-ID: <PM0003E7848D444E49@hades.none.local>


Kevin W. wrote:
> Hi,
>
> I have two tables. The PK are reversed.
>
> create table de_autotest_basic_s
> (c1 varchar2(8),
> c2 varchar2(12),
> c3 number,
> constraint test_basic_s PRIMARY KEY (c1,c2 )
> );
>
> create table de_autotest_basic_s
> (c1 varchar2(8),
> c2 varchar2(12),
> c3 number,
> constraint test_basic_s PRIMARY KEY (c2,c1 )
> );
>

[...]
>
> I got about one million rows with my tables. I wonder what
> will be the performance if I use:
>
> 1) select * from ...... order by "1,2"
> or
> 2) select * from ...... order by "2,1"
>
> to both tables.
>
> Same?
>

[...]

Hello Kevin,

yes the performance will be the same since no index is used ordering by character columns unless you are using nls_sort=BINARY. If you set nls_sort to BINARY I think the index is used if you order by the columns in index order.

Hope that helps,

Lothar

-- 
Lothar Armbrüster       | la_at_oktagramm.de
Hauptstr. 26            | la_at_heptagramm.de
D-65346 Eltville        | lothar.armbruester_at_t-online.de
Received on Thu Oct 28 2004 - 11:37:01 CDT

Original text of this message

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