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

SQL optimization

Former Member
0 Likes
693

Hi All,

How can you make the following statements faster? How do you optimize this?

Note: All fields. values and tables are for example purposes only. I am asking for a general answer.

DATA: it_test type hashed table of tabletype with unique key field1.

select distinct field1 from table1

into corresponding fields of table it_test

where field2 = 'value'

and field3 like 'value%'

and field4 = 'value'.

Thanks,

Kenny

Message was edited by: Kenny Martinez

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
666

arrenge field in internal table as same way u fetch from dbtab...(remove corresponding field)

select distinct field1 from table1

into of table it_test

where field2 = 'value'

and field3 like 'value%'

and field4 = 'value'.

5 REPLIES 5
Read only

Former Member
0 Likes
667

arrenge field in internal table as same way u fetch from dbtab...(remove corresponding field)

select distinct field1 from table1

into of table it_test

where field2 = 'value'

and field3 like 'value%'

and field4 = 'value'.

Read only

Former Member
0 Likes
666

Try these:

1. Create a secondary index with key fields field2, field3, field4

2. Ensure the fields in where condition are in the same order as they occur in the database table.

3. you may name write the query as

select distinct field1 from table1

into table it_field1

where field2 = 'value'

and field3 like 'value%'

and field4 = 'value'.

Note: the internal table now contains only one field. i.e., field1.

Read only

0 Likes
666

Hi Guys,

Sorry I forgot to mention that the tabletype of the it_test is table1.

thanks.

Kenny

Read only

Former Member
Read only

0 Likes
666

hey use

deleted adjecent duplicates insted of select disticnt ..

hope this helps ..

thanking you

rohit gupta