Application Development 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: 

Secondary index

Former Member
0 Kudos
152

Hi,

I have created a secondary index ZA2 for table LTAK with fileds LATER, PASSD and KQUIT.

In my Where clause:

Select * into <itab> from LTAK

where lgnum = plgnum AND

Kquit = 'X' and

passd = space

%HINTS MSSQLNT 'TABLE %TABLE% INDEX([LTAK~ZA2])'.

Is there anything wrong with Where clause, because i have not seen the better performence.

Thanks in advance.

narasimha

8 REPLIES 8

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
85

If you created the index on the following fields in this order,

LATER

PASSD

KQUIT

Then you should have LATER as the first field in your WHERE clause, otherwise your index is worthless.



Select * into <itab> from LTAK
<b>where later = 'whatever'
  and  Kquit = 'X' 
  and passd = space</b> 
%HINTS MSSQLNT 'TABLE %TABLE% INDEX([LTAK~ZA2])'.



If you WHERE clause was like this, then you would see a performance boost.

Regards,

Rich Heilman

Former Member
0 Kudos
85

Hi Rich,

Thanks for your quick response. I forgot to mention LATER in the where clause.

my code:

Select * into <itab> from LTAK

where lgnum = plgnum AND

Kquit = 'X' and

LATER IN (1,2,3) and

passd = space

%HINTS MSSQLNT 'TABLE %TABLE% INDEX([LTAK~ZA2])'.

I there any problm if field sequnce is different.

Thanks.

Former Member
0 Kudos
85

You must include all the fileds exactly the index you created and you can verify in the SQL trace whether the index picked or not while selecting the data.

Thanks,

Vamshi

0 Kudos
85

Again, the order of the fields in your WHERE clause is important. It must match the same order of the fields in your index. Then you will see a performance boost.

Regards,

Rich Heilman

Former Member
0 Kudos
85

Is it required to add LGNUM filed into the secondary index?

Thanks,

Narasimha

0 Kudos
85

I would, this will definitly help in your performance. Is there a reason why you didn't add it to begin with?

Regards,

Rich Heilman

Former Member
0 Kudos
85

Hi Rich,

There is no reason, actually the above select statement is a standard SAP statement in the function module L_TO_DN_READ. We are tying to improve the performence for the standard select statement.

Thanks,

Narasimha.

0 Kudos
85

There already is an index on lgnum and kquit for table LTAK. I don't know how much performance would improve if you add another field.

But since it's a standard SAP program, open an OSS note and let SAP analyze it.

Rob