Skip to Content
author's profile photo Former Member
Former Member

select query taking long on covp view

Hi techies ,

issue is want to get data from covp view for the list of company codes available ,
can you please look into the statement and edit .
heard we need to split the data from tables coep and cobk and then copy to covp .

awaiting replies ,
Thanks,

Praveen bindla.

pastedImage_0.png (346.9 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • Best Answer
    Posted on Dec 01, 2015 at 04:38 PM

    If you are selecting first into g_comp_code and then from covp, forget about the FOR ALL ENTRIES and use an INNER JOIN.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 01, 2015 at 02:37 PM

    It looks like you are trying to use the index based on TIMESTAMP. But if you look at that index in your system, you'll probably find that the index does not exist in the database.

    Rob

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      No, but I don't think the JOIN or FOR ALL ENTRIES is the problem either. It is probably the lack of using an index in the SELECT. There are indexes on both TIMESTAMP and KSTAR, but they are probably not in the database in your system. Please check to see if they exist in your system.

      Rob

  • Posted on Dec 01, 2015 at 03:20 PM

    Trx ST05 'SQL trace' will give you insight about use of indices during runtime.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2015 at 05:04 PM

    I would try this and run a SQL trace to analyze more.

    1. I will put KOKRS as the first field in WHERE clause as KOKRS is the key field(And the first field) for both COEP and COBK. At lest it will give a chance to the optimizer to use an index range scan. Also since KOKRS are normally very less for a system and it will surely have an impact as the probability to get an hit is high in this case.

    2. I am the pretty sure the for all entries is not required here . Company codes are normally not many for any system. Rather we can populate a range table for BUKRS using the entries in g_comp_code and use that in WHERE clause. And offcourse remove duplicates.

    3. Remove "BETWEEN" and create a range table using OPTION = 'BT' for timestamp and use that in where clause.

    R

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.