Solved

Index and column ordinal position

Posted on 2006-07-18
3
2,949 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 142

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 34

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video shows syntax for various backup options while discussing how the different basic backup types work.  It explains how to take full backups, incremental level 0 backups, incremental level 1 backups in both differential and cumulative mode a…
Via a live example, show how to take different types of Oracle backups using RMAN.

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now