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

select distinct

Former Member
0 Likes
713

Moved to correct forum by moderator

HI All,

can i write the querry as below. Is it good for performance issue?

SELECT DISTINCT vkorg spart FROM tvta

INTO TABLE lt_spart

WHERE spart IN spart

AND vkorg IN r_vkorg.

Edited by: Matt on Nov 24, 2008 2:40 PM

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
648

Hi

I think DISTINCT is nothing to do with the performance, the difference of using it or not is whether you

want repeat data.

6 REPLIES 6
Read only

Former Member
0 Likes
648

Is this part correct?

WHERE spart IN spart

Read only

0 Likes
648

yes that is correct

Read only

christine_evans
Active Contributor
0 Likes
648

>

> HI All,

>

>

> can i write the querry as below. Is it good for performance issue?

>

> SELECT DISTINCT vkorg spart FROM tvta

> INTO TABLE lt_spart

> WHERE spart IN spart

> AND vkorg IN r_vkorg.

If your TVTA table contains as few entries as ours does (only 6) then the performance of any type of select will be fantastic. Performance is always affected by data quantities. There is nothing wrong with using DISTINCT if that is what you want to do.

Read only

Former Member
0 Likes
649

Hi

I think DISTINCT is nothing to do with the performance, the difference of using it or not is whether you

want repeat data.

Read only

Former Member
0 Likes
648

Yes it is correct. Select Distinct will only remove the duplicate entries in your selection if there are any in you dbtable.

Thanks,

Jayant

Read only

0 Likes
648

>

> Yes it is correct. Select Distinct will only remove the duplicate entries in your selection if there are any in you dbtable.

>

> > Jayant

Yes, and to do so in a quick way, the select is "enriched" by the order by clause internally. It might be better to read everything into an internal table, sort this one and then do an delete ... duplictaes.

I would take this into consideration and compare the runtime analysis of both ways. Order by (even implicit ones) can cause a lot of performance issues when done on the table.