Solved

Index and column ordinal position

Posted on 2006-07-18
3
2,986 Views
Last Modified: 2007-12-19
Hi experts,

I recently added a new column to an existing table using
Alter table star12 add ID_GRP_RISK char(12)

The new field appears in last position when I run a desc on the table.

Now I need to create a new PK / Unique index using both the first column and the newly created one. Should column position be a concern.

I remember from my (old ;-) ) oracle days that column position might affect performances. I don't have the slightest idea if the version I use now (9i) has changed anything reagrding this column ordering.

Would a REORG be sufficient to get decent performances (after changing the unique index / primary key)

NB : dropping/creating the table to change its stucture was not an option.

Any comments welcome (I know I could find this kind of information on the net or simply browsing the KB .. I'm not lazy but my current mission does not leave me much time)

Hilaire
0
Comment
Question by:Hilaire
3 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 17130380
>Now I need to create a new PK / Unique index using both the first column and the newly created one. Should column position be a concern.
no. PK and indexes can be created on any column, whatever position they have in the table.
0
 
LVL 19

Expert Comment

by:actonwang
ID: 17130492
>>. Should column position be a concern.

      only the order you put into "create index ... on table1(col1,col2)" matters.
0
 
LVL 35

Assisted Solution

by:johnsone
johnsone earned 100 total points
ID: 17130610
That was always done for a few.

The first is looks.  The table looks better in the describe if the key fields are first.

They used to claim that there was a neglible performance increase in indexing if the key fields were first.  I never heard of anyone proving it though.

The biggest was storage.  Since disk is cheap now and storage is structured so much differently, that is not a concern anymore.

The storage savings is due to the fact that Oracle does not store trailing null columns.  This is why they had always suggested that all not null columns come first in the table.  Take these 2 tables for example:

test1 has columns a, b, and c.   a and c are not null and b is nullable.

test2 has columns a, c,  and b.  a and c are not null and b is nullable.

If b is null in test1, Oracle has to store a 1 byte length in the record.  If b is null in test2, nothing is stored in its place.

Over the course of millions of records and multiple columns, the space usage can add up.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
1 FROM DUAL wont work with additional columns ?? 4 55
Oracle SQL - Query help 7 78
Fill Date time Field 12 29
scheduler notification 9 27
Introduction A previously published article on Experts Exchange ("Joins in Oracle", http://www.experts-exchange.com/Database/Oracle/A_8249-Joins-in-Oracle.html) makes a statement about "Oracle proprietary" joins and mixes the join syntax with gen…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level with the mandatory Oracle Memory processes are as well as touching on some of the more common optional ones.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question