Solved

Index and column ordinal position

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

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…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
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 how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.

734 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