Problem : SELECT from LTAP table takes much time (Sort in Database layer)

Guys,
Im having problem with this select statement. It takes much time just to get single record.
The problem is with accessing the LTAP table and the ORDER BY DESCENDING statement.
The objective of this select statement is to get the non blocked storage bin which is used by latest transfer order number.
If the latest transfer order no storage bin is blocked, then it will loop and get the 2nd latest transfer order no's storage bin and
checks whether it blocked or not. It will keep looping.
The secondary index has been created but the it still taking much time (3 minutes for 10K records in LTAP)
Secondary Indexes:
a) LTAP_M ->MANDTLGNUM PQUIT MATNR
b)LTAP_L  ->LGNUM PQUIT VLTYP VLPLA
Below is the coding.
******************Start of DEVK9A14JW**************************
    SELECT ltaptanum ltapnlpla ltap~wdatu INTO (ltap-tanum, ltap-nlpla, ltap-wdatu)
          UP TO 1 ROWS
          FROM ltap INNER JOIN lagp                         "DEVK9A15OA
          ON lagplgnum =  ltaplgnum
          AND lagplgtyp =  ltapnltyp
          AND lagplgpla =  ltapnlpla
            WHERE lagp~skzue = ' '
            AND ltap~pquit = 'X'
            AND ltap~matnr = ls_9001_scrn-matnr
            AND ltap~lgort = ls_9001_scrn-to_lgort
            AND ltap~lgnum = ls_9001_scrn-lgnum
            AND ltap~nltyp = ls_9001_scrn-nltyp
      ORDER BY tanum DESCENDING.
     ENDSELECT.
    IF sy-subrc EQ 0.
      ls_9001_scrn-nlpla = ltap-nlpla.
      EXIT.
    ENDIF.
******************End of DEVK9A14JW**************************

> Im having problem with this select statement. It takes much time just to get single record.
This is not true. Together with the ORDER BY the UP TO 1 ROWS does not read 1 record but prepare all records, orders them and return one record, i.e. the largest in sort order.
You must check what you need, either you need the largest record, then this can be your only possible solution.
If you need only one recoird then the ORDER BY does not make sense.
If you need the single largest record, then sometimes the aggregate function MAX can be an alternative.
I did not look at the index support, this can always be a problem.
Siegfried

Similar Messages

  • Select from nested table in a nested table security problem

    please help
    running Oracle 9.2.0.3.0 on RH AS 2.1
    I can select the inner most nested table as the creator, but can't use the same select statement as USER2.
    ORA-00942: table or view does not exist
    -- begin make of objects and tables
    create or replace type mydata_t as object ( x float, y float);
    create or replace type mydata_tab_t as table of mydata_t;
    create or replace type mid_t as object (
         graphname varchar2(12),
         datapoints mydata_tab_t );
    create or replace type mid_tab_t as table of mid_t;
    create or replace type top_t as object (
         someinfo int,
         more_mid     mid_tab_t );
    create table xyz (
         xyzPK int,
         mainstuff     top_t )
         nested table mainstuff.more_mid store as mid_nt_tab
              (nested table datapoints store as mydata_nt_tab)
    -- grants
    grant all on mydata_t to user2;
    grant all on mydata_tab_t to user2;
    grant all on mid_t to user2;
    grant all on mid_tab_t to user2;
    grant all on top_t to user2;
    grant all on xyz to user2;
    -- insert
    insert into xyz values (1, top_t(22,mid_tab_t(mid_t('line1',mydata_tab_t(
    mydata_t(0,0),
    mydata_t(15,15),
    mydata_t(30,30))))));
    commit;
    -- select fails as user2
    select * from table(select Y.datapoints as DP_TAB
         from table(select X.mainstuff.more_mid as MORE_TAB
              from scott.xyz X
              where X.xyzPK=1) Y
         where Y.graphname='line1') Z;
    -- select works as user2, but i need individual lines
    select Y.datapoints as DP_TAB
         from table(select X.mainstuff.more_mid as MORE_TAB
              from scott.xyz X
              where X.xyzPK=1) Y
         where Y.graphname='line1';

    Thank you for your reply.
    I have tried
    select value(t) from table t;
    but it is still not working. I got almost the same answer as before.
    Anyway thank you very much again.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by MARCELO OCHOA ([email protected]):
    Originally posted by meimei wu ([email protected]):
    [b]I created a nested object-relational table using REF type in oracle8i. when I tried to select * from the table, I got lots of number as the ref type values, but actually, the value in ref type should be of type varchar2 and number. The number I got looked like following code:
    JARTICLE_REF_TYPE(000022020876108427C2FE0D00E0340800208FD71F76103B99B12009C0E0340800208FD71F,
    Does anyone know how I can get the actual value that I inserted into the nested table?
    your help is appreciated.<HR></BLOCKQUOTE>
    Try this:
    select value(t) from table t;
    Best regards, Marcelo.
    null

  • Query takes much time while sum of yearly bases amount

    I have made query on the basis of joing to get payroll data it's woking fine but when we accumulate this on yearly basis while giving parameter from and to date then it takes much time, so how can we optimise this.
    please advice.

    this is query
    SELECT paa.assignment_id,MAX(EFFECTIVE_DATE) effective_date,
    paypa.business_group_id,paypa.payroll_id,
    nvl(SUM(decode(pet.element_type_id,10,decode(pivf.name,'Pay Value',TO_NUMBER(NVL(prrv.result_value, 0))))),0) AMOUNT
    FROM pay_assignment_actions paa,
    pay_payroll_actions paypa,
    pay_run_results prr,
    pay_element_types_f pet,
    pay_element_classifications pec,
    pay_run_result_values prrv,
    pay_input_values_f pivf
    where paypa.payroll_ACTION_id = paa.payroll_ACTION_id
    AND prr.assignment_ACTION_id = paa.assignment_ACTION_id
    AND paypa.action_status = 'C'
    AND paa.action_status = 'C'
    and paypa.action_type in ('Q','R')
    AND pet.element_type_id = prr.element_type_id
    AND pec.classification_id = pet.classification_id
    AND pivf.input_value_id=prrv.input_value_id
    AND prr.run_result_id = prrv.run_result_id
    AND pivf.element_type_id = pet.element_type_id
    AND paypa.effective_date BETWEEN pivf.effective_start_date AND pivf.effective_end_date
    AND paypa.effective_date BETWEEN pet.effective_start_date AND pet.effective_end_date
    AND paypa.effective_date between to_date('01-JUL-2010') AND TO_DATE('30-JUN-2011')
    group by paa.assignment_id,paypa.business_group_id,paypa.payroll_id
    any idea for this ,how can we improve performance,althoug it's woking fine without using group by function
    Edited by: oracle0282 on Mar 31, 2011 11:36 PM

  • Primavera Contract managment take much time when open large PDF files.

    Dears,
    i have a big problem!
    i made integration between the PCM and sharepoint 2010 and make migration from the file system to sharepoint.
    the sharepoint database reach 355GB
    after that unfortunately, when i try to open large pdf attachment through PCM(Primavera Contract Managmnet) it take much time then whan was opened from the file server.
    i made everthing upgrde the RAM and processor but the problem still exists.
    please help!
    Edited by: 948060 on Sep 19, 2012 1:48 AM

    we start store attachment on 2007. all of these files are migrated to sharepoint 2010 now on the staging enviroment.
    but, we faced the performance issue as mentioned above.
    the large files (begin 5MB) take a lot of time to open through the PCM

  • How to avoid ORA-3113 when selecting from XMLTYPE table

    Hi,
    If I register an XML-schema, Oracle automatically creates a table xxxxxx_tab of XMLTYPE. (I use Oracle 9.2.0.1)
    When I do a DESCRIBE or a SELECT from this table I get the error: 'ORA-03113:
    end-of-file on communication channel' and my connection is dropped.
    I opened a TAR for this and Oracle says: 'It is an internal bug so cannot be viewed in metalink. This is fixed in release 10i.' (do they mean oracle DB rel 10i, or a new version of XDK?)
    I saw an example in Oracle Magazine (Jan
    2003) "Make XML Native and Relative" about Oracle 9i Rel 2 and XML. As you can see in codeListing 7, the author also does a select from such a
    table (CD331_tab): Why doesn't he have any problems?
    Is there a workaround for this bug? What's the purpose of being able to automatically upload XML-data to a registered schema if you can't do a select of the data?
    Thank you!

    It appears that the XML Schema is not entirely valid. Specifically, the definition of element "DeviceCategory" has two definitions of element "Audio" appearing within a <choice> model i.e. something like :
    <element name="DeviceCategory">
    <choice>
    <sequence>
    <element name="Audio">
    </sequence>
    <sequence>
    <element name="Audio">
    </sequence>
    </choice>
    This is disallowed by XML Schema spec per. the Unique Particle Attribution Constraint. The general idea is that a XML Schema describes a determinstic content model i.e. schema processor can always unambiguosly determine the matching declaration when it encounters an element. However that's not the case with the declaration above. On encoutering "Audio", it could match either the first or the second declaration of the element. Hence the error.
    You will have to rework the schema to avoid this constraint. One mechanism could be to define complexType and their restrictions.
    - Ravi

  • Select from a table from other schema

    Hi,
    I want to make a select from a table how is into other Schema and into other instance.
    form example, if I have _2 schemas (in diferent instances)_:
    SCHEMA1 =
    *(DESCRIPTION =*
    *(ADDRESS =*
    *(PROTOCOL = TCP)*
    *(HOST = XXX.XXX.XXX.XX1)*
    *(PORT = 1560)*
    *(CONNECT_DATA =*
    *(SERVER = DEDICATED)*
    *(SERVICE_NAME = SCHEMA1)*
    SCHEMA2 =
    *(DESCRIPTION =*
    *(ADDRESS =*
    *(PROTOCOL = TCP)*
    *(HOST = XXX.XXX.XXX.XX2)*
    *(PORT = 1560)*
    *(CONNECT_DATA =*
    *(SERVER = DEDICATED)*
    *(SERVICE_NAME = SCHEMA2)*
    and into SCHEMA2 there is a table TABLE_A.
    If I`m connected into SCHEMA1:
    how can I do to make a select from the TABLE_A?
    thanks very much.

    1) Referring to an entry in the tnsnames.ora file as a "schema" as you have here with schema1 and schema2 is likely to be confusing. You have multiple schemas in the same database-- in this case, you appear to be trying to query tables in a different database. If we try to answer using your TNS aliases "schema1" and "schema2", there is likely to be a great deal of confusion between schemas/ databases/ and TNS aliases. So I will assume that your tnsnames.ora file actually reads
    TNS_ALIAS1 =
      (DESCRIPTION =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = HOST1)
          (PORT = 1560)
        (CONNECT_DATA =
          (SERVER = DEDICATED)
          (SERVICE_NAME = DB1)
    TNS_ALIAS2 =
      (DESCRIPTION =
        (ADDRESS =
          (PROTOCOL = TCP)
          (HOST = HOST2)
          (PORT = 1560)
      (CONNECT_DATA =
        (SERVER = DEDICATED)
        (SERVICE_NAME = DB2)
    )2) Given the TNS aliases above, assuming that we are talking about the tnsnames.ora file on HOST1, you would need to create a database link from DB1 to DB2. You can either specify a fixed username and password for the database link or you can specify that the connection happens as the current user (which assumes that the passwords are synchronized between the databases).
    CREATE DATABASE LINK to_db2
      CONNECT TO username_on_db2
      IDENTIFIED BY password_on_db2
      USING 'TNS_ALIAS2'3) Assuming the database link is in place
    SELECT *
      FROM schema2.table_name@to_db2Justin

  • Selecting from two tables and confirming from them despites they not relate

    Please I need a query to select from two tables that are not related to each other.
    I also want to confirm data's as in verify wether what the user has entered is in accordance with what is in the tables
    Examples
    the first table is named "Card" and the second table is named "Student_Details"
    Card table contains a column named "Pin_Number".
    The Student_Details table contains fields such as Exam_Number, Name, Age, Sex.
    The user has to Enter the Pin_Number which has to be confirmed in the Card table and Exam_Number which has to be confirmed in the Student_Details table and verify that both data's are correct.
    Please I need the SQL and PL/SQL queries for this problem.
    Thanks

    Hi,
    I think you need two different queries
    You can write a procedure like:
    create or replace procedure p1 (p_pin_number number, p_exam_number)
    is
      r_card_row            card%rowtype;
      r_student_details     student_details%rowtype;
      cursor c1 is
      select *
        from card
       where pin_number = p_pin_number;
      cursor c2 is
      select *
        from student_details
       where exam_number = p_exam_number;
    begin
      open c1;
        loop
          fetch c1 into  r_card_row;
          exit when c1%notfound;
          ....  do whatever you want..... and the samething you can do with other cursor
        end loop;
      close c1;
    end p1;Hope this helps
    Ghulam

  • Takes much time

    hi all
    When i tries to retrive the data from outline using OLAP outline extractor it takes much time and less data
    i dont know whats the reason and where as in razzza i get in fraction of sec but its not format which ima looking for
    help appreciated
    regards

    You may need to make some registry settings, have a look at this post and there is a link to Tim's blog - Re: Extracting large dimension using outline extractor
    Cheers
    John
    http://john-goodwin.blogspot.com/

  • Selecting from multiple tables, into one internal table

    Hi,
    What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
    Thanks,
    John
    Points will be rewarded and all responses will be highly appreciated.

    I have simple example :
    First one - Join 5 tables
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 4 or 5 tables join.
    get run time field f2.
    f3 = f2 - f1 ( Total time).
    Second one - joins 3 table and use for all entries
    data : f1 type i,
              f2 type i,
              f3 type i.
    start-of-selection.
    get run time field f1.
    write the query 3 tables join and use for all entries
    get run time field f2.
    f3 = f2 - f1. ( Total time )
    Finally you can have time diffrence between the both sql statement.

  • MacBook Pro takes much time for Shutdown (More than 1 min.)

    I have a MacBook Pro, and some weeks ago, it takes much time for shutdown.
    I've tried to install the 10.5.2 update, but nothing solves.
    My mac takes for shutdown 1 min & 30 seconds every time. I don't understand. Why?
    What can I do? I tried to repair permissions and reset the PMU, but the problem still there.
    Help me! Please!
    Thanks
    Sorry, but I'm spanish and it's possible that I've made more mistakes writing in English.

    Thanks. I tried to dissable an EyeTv option, then EyeConnect don't appears in the Activity Monitor. This is the result:
    Now, my MacBook Pro takes only 35 seconds for shutdown. I think is better than yesterdey, but is more than the 5 seconds that you described in the last post. Is 35 seconds a good time? In this 35 seconds, I only can see the background image, without icons and without the finder menu bar. After 35 seconds, Mac is off.
    How can I disable iDisk sync? I have a free mac Account, but is expired and then I can't use iDisk, only the name in iChat. But, is iDisk enabled?

  • SSMS is not listing table and views objects though the objects are listed when I execute TSql string "SELECT * FROM sys.Tables"

    I have a db, call it xyz.mdb
    It suddenly is that SSMS is not listing the table objects nor the Views.  SELECT * FROM sys.Tables and SELECT * FROM sys.Views work very fine.  But when I click on the tables node, on Objects Explorer, Only the Systems Tables and File Tables folders
    show. 
    Other DBs on same SQL instance do not show same problem.  They are all working very fine.
    I have backed up and restored this db on other computers and the behaviour is the same.  Incidentally right-clicking the db and clicking Properties throws up this error message.
    -------------------------------------------------------------------------Error!
    Cannot show requested dialog.
    Property Size is not available for Database '[Pliny E DB - NOA 2014]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights.  (Microsoft.SqlServer.Smo)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1325+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.PropertyCannotBeRetrievedExceptionText&EvtID=Size&LinkId=20476
    --------------------------------------------------------------------------------End>
    When I try to Refrresh the Tables node on Object Explorer, I get this other:
    ------------------------------Error!
    SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0x9090d9b7; actual: 0x909001b4). It occurred during a read of page (1:1173) in database ID 21 at offset 0x0000000092a000 in file 'c:\Databases\Clients\NOA\Pliny E DB -
    NOA 2014.mdf'.  Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check
    (DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. (Microsoft SQL Server, Error: 824)
    For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476
    ------------------------------End>
    The Help link of course is not valid any more.
    Many thanks
    Vie
    @Abuja
    Vie

    Your database is corrupted and you need to run.
    DBCC CHECKDB
    You already have a backup so do it...
    This link will provide you with more information:
    http://msdn.microsoft.com/en-us/library/ms176064.aspx

  • Select from multiple tables without join statement

    Hey Gurus,
    I would like to make a select from a multiple tables to check if there is any reference to my data. I would like to do it with some elegancy, but I don't know how.
    Is in abap sql possible to do it only with the select statement?
    Or I was also think about a solution that I should fill some data structure with all of the tables which I want to select from and then just loop that data structure and do the select seperately from all of the tables. I just need to check if it founds some results, so no need to store it. If this solution would be fine what data structure should I use?
    Or can tell me what would be the best for this?
    My code for select from one table, which I want to make for multiple tables:
    SELECT SINGLE id_kniznice FROM zbr_t_autori INTO wa_id
           WHERE id_kniznice EQ ls_extract-zview-id_kniznice.
         IF sy-dbcnt > 0.
           MESSAGE i000(zbr_msgc_lib).
           ls_extract-flags-vim_mark = '*'.
           MODIFY extract FROM ls_extract.
    ENDIF.   
    Thank you for any posts.
    Regards,
    Robert

    And there we go again...
    Read this topic:
    For All Entries is NOT better than INNER JOIN in most cases
    And this one:
    inner join vs for all entries
    Also that one:
    Re: LOOP AT vs INNER JOIN
    JOINs are really better than for all entries in most cases. Problem is people tend to ignore basic things like using pks or indexes while making them.

  • Dynamic SQL select from unknown table until runtime

    I need to do a select from a table that is unknown until runtime. Is there any good examples of this. The Store Procedure will take in the table name and return a row.
    I am not using inline SQL because there is a lot more complexity involved . What I need to do is understand how to reference this unknown table.
    Here is an example of what I have written so far.
    PACKAGE pk_LoadNativeDataItems IS
    PROCEDURE version;
    TYPE RowDataCur IS REF CURSOR;
    PROCEDURE pr_LoadNativeDataItems(p_flag IN NUMBER
    p_how_many_rows_to_fetch IN NUMBER,
    p_row_data OUT RowDataCur);
    PROCEDURE pr_LoadNativeDataItems(p_flag IN NUMBER
    p_how_many_rows_to_fetch IN NUMBER,
    p_table_name IN VARCHAR,
    p_row_data OUT RowDataCur) IS
    BEGIN
    OPEN p_row_data FOR
    SELECT * from ||p_table_name||;
    END pr_LoadNativeDataItems;
    END pk_LoadNativeDataItems;
    Thanks for any help
    Tony

    Here is example for similar question:
    Using variables for tables and columns

  • Value select from nested table

    CREATE TYPE test AS OBJECT (
    test1 varchar2(10),
    test2 varchar2(10));
    create or replace type test2 as table of test;
    two record are there within object type.then how i will select value from nested table.

    How many times are you going to ask this question before you either look at the response I have given to Re: how i will display type like (nestedtable or varrays or pl/sql table).?
    You have posted often enough to this forum to know the ettiquette by now.
    Regards, APC

  • Urgent. . .About select * from multiple tables

    When I am doing the 'Select * from tables' in JSP,
    sql = dbconn.prepareStatement("SELECT * FROM protein WHERE protein_id ='"+p_i+"'");
    It works, because I only select one table.
    Then, I change to select from two tables,
    sql = dbconn.prepareStatement("SELECT * FROM protein, fuses WHERE protein_id ='"+p_i+"'");
    It also works properly?
    However, When I do like:
    sql = dbconn.prepareStatement("SELECT * FROM protein, protein_taxa WHERE protein_id ='"+p_i+"'");
    It doesn?t work.
    So, I think it might be the problem that there is a common column 'protein_id' in both tables, although protein_taxa.protein_id is a foreign key of protein.protein_id. Therefore, I can select two table protein, fuses which have different columns, but no way to select the table they have same name column.
    However, it?s essential for me to select all the data from the database. Any way I could achieve it? Thanks a lot!!

    SELECT *
    FROM protein, protein_taxa
    WHERE protein.protein_id = 'a_protein_id'
    and protein.protein_id = protein_taxa.protein_id It would also be good to indicate which fields you want on the select clause. This will liberate the server to return two fields with the same name.
    SELECT protein.protein_id, protein.name, protein_taxa.taxa /* ??? */
    FROM protein, protein_taxa
    WHERE protein.protein_id = 'a_protein_id'
    and protein.protein_id = protein_taxa.protein_id

Maybe you are looking for