Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Primary Key Vs Index

Former Member
0 Likes
865

Hi all,

Here is a very basic question?

I am selecting data from a database table for e.g. KNA1. In order to quickly fetch data from this table, is it always adviceable to use available indexes along with the primary key fields?

Along with kunnr, should I look for some other indexes?

Thanks,

Rajan

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
681

Hi Rajan ,

One thing is sure ., for your selection requirement if you can get data based on KUNNR ,

u can directly use that with out thinking of any Index keys .

If in your selection criteria if there are any other fields go for index other wise not required as the each index will be created with its own Key field structure .

Thanks

Sreenivas Reddy

3 REPLIES 3
Read only

Former Member
0 Likes
681

> I am selecting data from a database table for e.g. KNA1. In order to quickly fetch data

> from this table, is it always adviceable to use available indexes along with the primary key fields?

It is very unclear what you mean

a table has some fields

some fields in front are marked as keys, they are the key fields and build a unique key for the

table

the primary key or index is build out of the key fields

there can be other indexes they use other fields

Now what is your question?

If you use KNA1, then kunnr is the second keyfield, mandt come automatically, so

the full unique key is specified, only one record can be found.

Additional records can make sense, for example if you select with FOR ALL ENTRIES a number

of customers, with 1000 kunnr, you would get 1000 records (if they all exist). But if they must

fulfill additional conditions, for example come from a certain land, then you add this condition.

The search becomes not faster all 1000 customers are checked, but not all are transferred.

Siegfried

Read only

Former Member
0 Likes
682

Hi Rajan ,

One thing is sure ., for your selection requirement if you can get data based on KUNNR ,

u can directly use that with out thinking of any Index keys .

If in your selection criteria if there are any other fields go for index other wise not required as the each index will be created with its own Key field structure .

Thanks

Sreenivas Reddy

Read only

0 Likes
681

Thanks Sreeni,

So, Now I believe, if I have primary key it is not necessary to look for indexes for quick data retrieval.