Solved

Index and column ordinal position

Posted on 2006-07-18
3
3,015 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious sideā€¦
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.

695 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