How can i optimize this query

SELECT c1,c2 FROM tabla WHERE c1=(SELECT MIN(c1) FROM tabla)
(i want to get an unique register which contains the minimum value in the table for the field c1)

                                    C1                                     C2
                                     1                                     -1
                                     2                                     -2
                                     3                                     -3
                                     4                                     -4
                                     5                                     -5
                                     6                                     -6
                                     7                                     -7
                                     8                                     -8
                                     9                                     -9
                                    10                                    -10
10 rijen zijn geselecteerd.
SQL>
SQL> SELECT c1,c2 FROM tabla WHERE c1=(SELECT MIN(c1) FROM tabla)
  2  /
                                    C1                                     C2
                                     1                                     -1
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   FILTER
   2    1     TABLE ACCESS (FULL) OF 'TABLA'
   3    1     SORT (AGGREGATE)
   4    3       TABLE ACCESS (FULL) OF 'TABLA'
SQL>
SQL> SELECT c1,c2
  2          FROM
  3                  (
  4                  SELECT c1,c2, ROW_NUMBER() OVER (ORDER BY C1) RN
  5                          FROM tabla
  6                  )
  7          WHERE RN = 1
  8  /
                                    C1                                     C2
                                     1                                     -1
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   VIEW
   2    1     WINDOW (SORT PUSHED RANK)
   3    2       TABLE ACCESS (FULL) OF 'TABLA'
SQL>
SQL> select min(c1) keep (dense_rank first order by c1) c1
  2       , min(c2) keep (dense_rank first order by c1) c2
  3    from tabla
  4  /
                                    C1                                     C2
                                     1                                     -1
Execution Plan
   0      SELECT STATEMENT Optimizer=CHOOSE
   1    0   SORT (AGGREGATE)
   2    1     TABLE ACCESS (FULL) OF 'TABLA'Regards,
Rob.

Similar Messages

  • Can anyone tell me how can i optimize this query...

    Can anyone tell me how can i optimize this query ??? :
    Select Distinct eopersona.numident From rscompeten , rscompet , rscv , eopersona , rscurso , rseduca , rsexplab , rsinteres
    Where ( ( (LOWER (rscompeten.nombre LIKE '%caracas%') AND ( rscompeten.id = rscompet.idcompeten ) AND ( rscv.id = rscompet.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.nombre) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscurso.lugar) LIKE '%caracas%') AND ( rscv.id = rscurso.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rseduca.univinst) LIKE '%caracas%)' AND ( rscv.id = rseduca.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsexplab.nombempre) LIKE '%caracas%' AND ( rscv.id = rsexplab.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rsinteres.descrip) LIKE '%caracas%' AND ( rscv.id = rsinteres.idcv ) AND ( eopersona.id = rscv.idpersona ) )
    OR ( (LOWER (rscv.cargoasp) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona ) )
    OR ( LOWER (eopersona.ciudad) LIKE '%caracas%' AND ( eopersona.id = rscv.idpersona )
    PLEASE IF YOU FIND SOMETHING WRONG.. PLEASE HELP ME.. this query takes me aproximatelly 10 minutes and the database is really small ( with only 200 records on each table )

    You are querying eight tables, however in any of your OR predicates you're only restricting 3 or 4 of those tables. That means that the remaining 4 or 5 tables are generating cartesian products. (n.b. the cartesian product of 5 tables with 200 rows each results in g 200^5 = 320,000,000,000 rows) Then you casually hide this behind "distinct".
    A simple restatement of your requirements looks like this:
    Select eopersona.numident
      From rscompeten,
           rscompet,
           rscv,
           eopersona
    Where LOWER (rscompeten.nombre) LIKE '%caracas%'
       AND rscompeten.id = rscompet.idcompeten
       AND rscv.id = rscompet.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.nombre) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    Select eopersona.numident
      From rscurso ,
           rscv,
           eopersona
    Where LOWER (rscurso.lugar) LIKE '%caracas%'
       AND rscv.id = rscurso.idcv
       AND eopersona.id = rscv.idpersona
    UNION
    ...From there you can eliminate redundancies as desired, but I imagine that the above will perform admirably with the data volumes you describe.

  • How can I optimize this query's performance

    SELECT pu.user_id,
    cd.owner,
    cd.somedata
    FROM client_detail cd,
    client_detail_user_xref pu
    WHERE cd.device_id = 'xxxxxxxxx'
    AND cd.client_detail_id = pu.client_detail_id(+)
    AND(cd.alt_user_id = '12345' OR pu.user_id = '67890')
    Plan hash value: 3532311591
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 247 | 1374 (1)| 00:00:17 |
    |* 1 | FILTER | | | | | |
    | 2 | NESTED LOOPS OUTER | | 1 | 247 | 1374 (1)| 00:00:17 |
    |* 3 | TABLE ACCESS FULL | CLIENT_DETAIL | 1 | 226 | 1371 (1)| 00:00:17 |
    | 4 | TABLE ACCESS BY INDEX ROWID| CLIENT_DETAIL_USER_XREF | 1 | 21 | 3 (0)| 00:00:01 |
    |* 5 | INDEX RANGE SCAN | CLIENT_DETAIL_USER_PK | 1 | | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    1 - filter("CD"."ALT_USER_ID"='12345' OR "PU"."USER_ID"='67890')
    3 - filter("CD"."DEVICE_ID"='xxxxxxxxx')
    5 - access("CD"."CLIENT_DETAIL_ID"="PU"."CLIENT_DETAIL_ID"(+))
    Edited by: user13805875 on Feb 24, 2011 5:13 AM

    If you are posting a Performance Related Question. Please read
    {thread:id=501834} and {thread:id=863295}.
    Following those guide will be very helpful.

  • How can i improve this query.

    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .

    952936 wrote:
    Hi guys i am beginner , just wanted to know some info , how can i improve this query ..
    select *
    from tableA A, viewB B,
    where A.key = B.key
    and a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    one more thing should function should be on left side of equal sign.
    will a join make it better or something else is needed more than that .If you are a beginner try to learn the ANSI Syntax. This will help you a lot to write better queries.
    Your select would look like this in ANSI.
    select *
    from tableA A
    JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_function(a.key);The good thing here is that this separates the typical joining part of the select from the typical filter criteria.
    The other syntax very often let you forget one join. Just because there are so many tables and so many filters, that you just don't notice correctly anymore what was join and what not.
    If you notice that the number of column is not what you expect, you can easiely modify the query and compare the results.
    example A
    Remove View B from the query (temporarily comment it out).
    select *
    from tableA A
    --JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)
    example B
    You notice, that values from A are missing. Maybe because there is no matching key in ViewB? Then change the join to an outer join.
    select *
    from tableA A
    LEFT OUTER JOIN viewB B ON A.key = B.key
    WHERE a.criteria1 = '111'
    and a.criteria2 = some_funtion(a.key)(The outer keyword is optional, left join would be enough).

  • HT201210 I am trying to update Ios7 for iPhone 4 but there is an unknown error occurred like (-23). My Laptop OS is Windows 8. Now how can i solved this query.

    Dear Sir/Madam
    I am trying to update Ios7 for iPhone 4 but there is an unknown error occurred like (-23). My Laptop OS is Windows 08.ios 7 update which can updated and remaining  30minutes are left out. Than after error which can be show as i have mentioned above.
    How can i resolved this error? So please help me.
    Thanks & Regards,
    Vatsal Desai

    Error 20, 21, 23, 26, 28, 29, 34, 36, 37, 40
    These errors typically occur when security software interferes with the restore and update process. Use the steps to troubleshoot security software issues to resolve this issue. In rare cases, these errors may be a hardware issue. If the errors persist on another computer, the device may need service.
    Also, check your hosts file to verify that it's not blocking iTunes from communicating with the update server. See the steps under the heading "Blocked by configuration (Mac OS X / Windows) > Rebuild network information > Mac OS X > The hosts file may also be blocking the iTunes Store." If you have software used to perform unauthorized modifications to the iOS device, uninstall this software prior to editing the hosts file to prevent that software from automatically modifying the hosts file again on restart.
    all of this from
    iTunes: Specific update-and-restore error messages and advanced troubleshooting

  • How can i run this query in BI Answers

    Hi,
    pls tell me how can i run this sql statement in BI Answers....???
    select abc_date,abc_asset_desc,sum(nvl(abc_market_val_lcy,0)+nvl(abc_accr_lcy,0)) "total balance" from abc
    group by abc_date,abc_asset_desc;any help would be appriciated.... :-)
    Regards

    Strange question this one.
    normally with Answers you pick the columns you want to report on and the BI server will construct the SQL for you.
    In this example you would need a star with the abc dimension logical table and a logical fact for abc (these can be in the same table), which has a calculated field for 'Total Balance'.
    You then pick the columns you require and Answer and the BI will automatically add the group by.
    Adrian
    Majendi

  • How can i make this query run for a form

    This query works fine for a sql report
    SELECT *
    FROM STUDENTS
    WHERE given_name||' '||family_name = :P101_USERNAME
    AND password = :P101_PASSWORD;
    But i want it to do the same thing for a form but i dont have the option like i do for the report where i can just apply the condition to the process.
    Anyone any ideas how i could do this so that when i go to the form this information is already there based on the username and password from the previous page?

    Assuming that page 101 is your login form, just lookup the primary key of the student based on the values presented in the login page fields, then set and pass this value to the form page.
    So you would create a process that runs near the very end of the the login processes on page 101, something like this:
    declare
    l_student_id students.student_id%TYPE;
    begin
    select student_id into l_student_id from students where  given_name||' '||family_name = :P101_USERNAME and password = :P101_PASSWORD;
    -- then set the value of your form page primary key field
    :P1_STUDENT_ID := l_student_id;
    end;I've done something similar and it works fine for me, although I haven't looked at it recently.
    Earl

  • How can i construct this query without using CASE statement?

    I've a following code. I'm using this script in Hibernet. So, i cannot use CASE there. Because, hibernet doesn't support case in select statement. How can i construct the same thing which will give me the same result without using CASE?
    SELECT ofc.FLT_LCL_ORIG_DT
         , ofc.CARR_IATA_CD
         , ofc.FLT_NBR
         , ofc.ORIG_ARPT_CD
         , ofc.DEST_ARPT_CD
         , sum( ofc.CNCT_PSGR_CNT) AS BOOKED_CNCT_PSGR_CNT
         , sum( CASE WHEN o.fsdr_mrkt_cd = 'D' AND d.fsdr_mrkt_cd = 'D'           THEN '0'
            ELSE to_char(ofc.CNCT_PSGR_CNT,'99')                             END ) AS BOOKED_INTL_CNCT_PSGR_CNT
         , sum(CASE WHEN o.fsdr_mrkt_cd||d.fsdr_mrkt_cd = 'DD'
                    THEN '0'
            ELSE to_char(ofc.CNCT_PSGR_CNT,'99')
            END) AS NEW_BCNT
    FROM OPS_FLT_CNCT ofc
                        , STN o
                        , STN d
                    WHERE ofc.CNCT_ORIG_ARPT_CD = o.STN_CD
                      AND ofc.CNCT_DEST_ARPT_CD = d.STN_CD
                     -- AND TRUNC(ofc.FLT_LCL_ORIG_DT) = trunc(to_date('22-MAY-2007','DD-MON-YYYY'))
                      AND ofc.CARR_IATA_CD = 'UA'
                      AND ofc.FLT_NBR = '1218'
                      AND ofc.ORIG_ARPT_CD = upper('DEN')                AND ofc.DEST_ARPT_CD = upper('IAD')                  GROUP BY ofc.FLT_LCL_ORIG_DT
                           , ofc.CARR_IATA_CD
                           , ofc.FLT_NBR
                           , ofc.ORIG_ARPT_CD
                           , ofc.DEST_ARPT_CD ;And, the output look like this --
    FLT_LCL_O CARR FLT_N ORI DES BOOKED_CNCT_PSGR_CNT BOOKED_INTL_CNCT_PSGR_CNT   NEW_BCNT
    22-MAY-07 UA   1218  DEN IAD                    9                         0          0
    23-MAY-07 UA   1218  DEN IAD                    1                         0          0
    24-MAY-07 UA   1218  DEN IAD                    2                         1          1
    25-MAY-07 UA   1218  DEN IAD                    1                         0          0Thnaks in advance for reply.
    Regards.
    Satyaki De.
    #####

    2 ideas:
    1. Inline function to perform the CASE funcionaltity for you
    2. Piplelined function to generate the entire dataset
    Both will be slower than just using CASE in a query, but we're working around big constraints

  • How can we rewrite this query for better performance

    Hi All,
    The below query is taking more time to run. Any ideas how to improve the performance by rewriting the query using NOT EXITS or any other way...
    Help Appreciated.
    /* Formatted on 2012/04/25 18:00 (Formatter Plus v4.8.8) */
    SELECT vendor_id
    FROM po_vendors
    WHERE end_date_active IS NULL
    AND enabled_flag = 'Y'
    and vendor_id NOT IN ( /* Formatted on 2012/04/25 18:25 (Formatter Plus v4.8.8) */
    SELECT vendor_id
    FROM po_headers_all
    WHERE TO_DATE (creation_date) BETWEEN TO_DATE (SYSDATE - 365)
    AND TO_DATE (SYSDATE))
    Thanks

    Try this one :
    This will help you for partial fetching of data
    SELECT /*+ first_rows(50) no_cpu_costing */
    vendor_id
    FROM po_vendors
    WHERE end_date_active IS NULL
    AND enabled_flag = 'Y'
    AND vendor_id NOT IN (
    SELECT vendor_id
    FROM po_headers_all
    WHERE TO_DATE (creation_date) BETWEEN TO_DATE (SYSDATE - 365)
    AND TO_DATE (SYSDATE))
    overall your query is also fine, because, the in this query the subquery always contain less data compare to main query.

  • How can i speedup this query ?

    Hi,
    have a look at this query:
    SELECT DISTINCT element_short_description
               FROM sample_test_report, test_group, test_element_master
              WHERE str_test_group_code = tgr_test_group_code
                AND str_element_code = element_code
                AND tgr_group_description = 'SINTER_CHEMICAL_ANALYSIS'
           ORDER BY element_short_descriptionThing is that total number of rows present in "sample_test_report" tables are in lakh ...around 50 lakh.Other two tables have a few rows. This query is taking around 15 seconds for completion, can this query be made faster ?
    Note that proper indexing have been done already.
    Thanks.

    SELECT DISTINCT element_short_description
    FROM sample_test_report, test_group, test_element_master
    WHERE str_test_group_code = tgr_test_group_code
    AND str_element_code = element_code
    AND tgr_group_description = 'SINTER_CHEMICAL_ANALYSIS'
    ORDER BY element_short_description
    Can you provide us with explain plan?
    I suggest you use table alias every time:
    The alias is specified in the FROM clause after each table name.
    Table aliases make your queries more readable.
    Then gather statistics your tables:
    BEGIN
    DBMS_STATS.GATHER_TABLE_STATS('OWNER','TABLE',estimate_percent=>NULL,method_opt=>'FOR ALL INDEXED COLUMNS SIZE AUTO',DEGREE=>10,CASCADE=>TRUE,granularity=>'ALL');
    END;
    if your db version < 10g
    ANALYZE TABLE employees COMPUTE STATISTICS;
    ANALYZE TABLE employees ESTIMATE STATISTICS;
    If necessary rebuild index, check indexes are use.
    Unusable indexes are made valid by rebuilding them to recalculate the pointers.
    Rebuilding an unusable index re-creates the index in a new location, and then drops the unusable index. This can be done either by using Enterprise Manager or through SQL commands:
    ALTER INDEX HR.emp_empid_pk REBUILD;
    ALTER INDEX HR.emp_empid_pk REBUILD ONLINE;
    ALTER INDEX HR.email REBUILD TABLESPACE USERS;
    Note: Rebuilding an index requires that free space be available for the rebuild. Verify that there is sufficient space before attempting the rebuild. Enterprise Manager checks space requirements automatically.
    At the end, try join table separately and then concatenate them.
    Your query will be work good.
    Look at execution plan, if indexes are not used, use HINTs : There are many Oracle hints available to the developer for use in tuning SQL statements that are embedded in PL/SQL.
    please refer to http://www.dba-oracle.com/t_sql_hints_tuning.htm and http://www.adp-gmbh.ch/ora/sql/hints/index.html
    Good luck

  • How can i optimize this querie

    Hi oracle developers i want this query gonna be faster than it is but i cant find the way. With functions the result was improved but not enough. Anybody can help me. Exist sometool that i can use.
    With explain Plan shows this:
    HASH Join
    Table Acces Full predetalle
    TableAcces Full funciones
    SELECT fun.fun_codigo                                   FUNCION
    ,fun.fun_desc FUNDESC
    ,SUM(NVL(pdt.pdt_disp,0)) DISPONIBLE
    ,SUM(NVL(pdt.pdt_apart,0)) APARTADO
    ,SUM(NVL(pdt.pdt_comp,0)) COMPROMETIDO
    ,SUM(NVL(pdt.pdt_real,0)) REAL
    ,SUM(NVL(pdt.pdt_presup,0)) PRESUPUESTADO
    ,SUM(pk_presupuestos.SumRealAcumuladoByFuncion(pdt.pdt_fun_codigo, pdt.pdt_per_anio, pdt.pdt_per_period, pdt.pdt_con_codigo)) REALACUM
    ,SUM(pk_presupuestos.SumPresAcumuladoByFuncion(pdt.pdt_fun_codigo, pdt.pdt_per_anio, pdt.pdt_per_period, pdt.pdt_con_codigo)) PRESUPACUM
    ,SUM(pk_presupuestos.SumRealAnualByFuncion(pdt.pdt_fun_codigo ,pdt.pdt_per_anio ,pdt.pdt_con_codigo)) REALANUAL
    ,SUM(pk_presupuestos.SumPresAnualByFuncion(pdt.pdt_fun_codigo ,pdt.pdt_per_anio ,pdt.pdt_con_codigo)) PRESUPANUAL
    ,fun.fun_tipo TIPO
    FROM FUNCIONES fun
         ,PREDETALLE pdt
    WHERE pdt.pdt_fun_codigo = fun.fun_codigo--fun.fun_codigo = pdt.pdt_fun_codigo
    AND pdt.pdt_per_anio = :anio
    AND pdt.pdt_per_period = :periodo
    AND pdt.pdt_vigente = 'V'
    AND ( :usuario IN (SELECT ful_empl_id FROM FUNNIVEL WHERE ful_fun_codigo = pdt.pdt_fun_codigo)
    OR :usuario IN (SELECT vep_empl_id FROM VERPRESUP WHERE vep_fun_codigo = pdt.pdt_fun_codigo)
    OR :usuario IN (SELECT fun_empl_resp FROM FUNCIONES WHERE fun_codigo = pdt.pdt_fun_codigo))
    GROUP BY fun.fun_codigo
    ,fun.fun_desc
    ,fun.fun_tipo;

    You might try replacing the multiple IN statements with
    AND :usuario IN (SELECT ful_empl_id
                       FROM FUNNIVEL
                       WHERE ful_fun_codigo = pdt.pdt_fun_codigo
                       UNION ALL
                       SELECT vep_empl_id
                       FROM VERPRESUP
                       WHERE vep_fun_codigo = pdt.pdt_fun_codigo
                       UNION ALL
                       SELECT fun_empl_resp
                       FROM FUNCIONES
                       WHERE fun_codigo = pdt.pdt_fun_codigo)TTFN
    John

  • How can i optimize this method

    protected String getTheRealKey(String currentLevel, String keyWithStar) {
    int starIndex = keyWithStar.indexOf("*");
    String keyInCollection;
    while (starIndex != -1) {
    keyInCollection = StringValue.first(currentLevel.substring(starIndex));
    keyWithStar = keyWithStar.substring(0, starIndex) + keyInCollection + keyWithStar.substring(starIndex+1);
    starIndex = keyWithStar.indexOf("*");
    return keyWithStar;
    }

    I do not see how you could optimize it further unless you wanted to use RegEx via String.replaceAll() in 1.4 and higher. However, it is rare that string manipulation will be your scaling bottleneck.
    - Saish

  • How can i optimize this SQL

    Is there anyway i could optimize the below mentioned SQL. Since our test DB is down now, i'll be posting the EXPLAIN PLAN later.
    Is there anything i could do syntactically to optimize this sql?
    SELECT SUBSTR(STK_INF.TASK_GENRTN_REF_NBR,1,12) AS PICK_WAVE_NBR,
                     ( CASE WHEN ( SUM(STK_INF.QTY_ALLOC) > 0 ) THEN
            ROUND ( (SUM(CASE WHEN (STK_INF.NEXT_TASK_ID = 0 AND STK_INF.ALLOC_INVN_DTL_ID = 0) THEN
            STK_INF.QTY_ALLOC ELSE 0 END ) / (SUM(STK_INF.QTY_ALLOC))),2 ) * 100
            ELSE 0 END ) AS PICK_PER,
         ( CASE WHEN ( SUM(STK_INF.QTY_ALLOC) > 0 ) THEN
           ROUND( (SUM(CASE WHEN (STK_INF.NEXT_TASK_ID = 0 AND STK_INF.ALLOC_INVN_DTL_ID = 0) THEN
           STK_INF.QTY_PULLD ELSE 0 END ) / (SUM(STK_INF.QTY_ALLOC))),2 ) * 100
           ELSE 0 END ) AS TILT_PERCENT
         FROM STK_INF, TRK_DTL
         WHERE STK_INF.TASK_GENRTN_REF_CODE = '44' AND STK_INF.CARTON_NBR IS NOT NULL
          AND ((STK_INF.NEXT_TASK_ID = 0 AND STK_INF.STAT_CODE <= 90) OR (STK_INF.NEXT_TASK_ID > 0 AND STK_INF.STAT_CODE < 99))
          AND PULL_LOCN_ID = TRK_DTL.LOCN_ID(+) AND (TRK_DTL.AREA <>'C' OR TRK_DTL.AREA IS NULL)
         GROUP BY SUBSTR(STK_INF.TASK_GENRTN_REF_NBR,1,12)

    This is the EXPLAIN PLAIN i got after i issued EXECUTE DBMS_STATS.GATHER_TABLE_STATS ('schema_name','table_name'); for both the tables involved.
    The number of row returned is still 222 rows. But in the EXPLAIN PLAN it is shown as 3060 !!
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    Plan hash value: 3267659036
    | Id  | Operation               | Name     | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT        |          |  3060 |   194K|       | 16527  (10)| 00:03:19 |
    |   1 |  HASH GROUP BY          |          |  3060 |   194K|       | 16527  (10)| 00:03:19 |
    |*  2 |   FILTER                |          |       |       |       |            |          |
    |*  3 |    HASH JOIN RIGHT OUTER|          |   177K|    11M|  7344K| 16397  (10)| 00:03:17 |
    |   4 |     TABLE ACCESS FULL   | TRK_DTL |   313K|  3669K|       |  2378   (6)| 00:00:29 |
    |*  5 |     TABLE ACCESS FULL   | STK_INF |   177K|  9205K|       | 13030  (11)| 00:02:37 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       2 - filter("TRK_DTL"."AREA"<>'C' OR "TRK_DTL"."AREA" IS NULL)
       3 - access("PULL_LOCN_ID"="TRK_DTL"."LOCN_ID"(+))
       5 - filter("STK_INF"."CARTON_NBR" IS NOT NULL AND
                  "STK_INF"."TASK_GENRTN_REF_CODE"='44' AND ("STK_INF"."NEXT_TASK_ID"=0 AND
                  "STK_INF"."STAT_CODE"<=90 OR "STK_INF"."NEXT_TASK_ID">0 AND
                  "STK_INF"."STAT_CODE"<99))
    22 rows selected.You mentioned about creating indexes in STK_INF table. STK_INF.NEXT_TASK_ID has 186385 distinct values out of a total 782087. Does NEXT_TASK_ID make a good candidate for a B-Tree index
    STK_INF.STAT_CODE has only four distinct values, would this make a good candidate for a Bitmap index?

  • How can I write this query

    Customer Trans          Transaction     Invoice
    Code     Date Type      Amount
    A001     01-JAN-2004     invoice      1000
    A001     01-FEB-2004      Receipt      -1500
    A001     01-MAR-2004     invoice          2000
    A001     01-APR-2002     invoice          2500
    OUTPUT wanted to be...
    Customer Trans     Transaction     Invoice          
    Code     Date Type      Amount     Balance
    A001 01-JAN-2004 invoice 1000          1000
    A001     01-FEB-2004 receipt -1500          500     
    A001     01-MAR-2004 invoice     2000          2500
    A001     01-APR-2002 invoice     2500          5000
    Hi All,
    Please look into the above data, If analytic function LAG(),CASE expression are possible to locate the cursor position in the single query, then any one can help me out about it. I tried but could not.
    Regards,
    Neel.

    You can do this with the SUM analytic function. Taking the emp table, for example,
      1  select ename, sal, SUM(sal) OVER (order by empno)
      2    from emp
      3*  order by empno
    SQL> /
    ENAME                                 SAL SUM(SAL)OVER(ORDERBYEMPNO)
    SMITH                                 800                        800
    ALLEN                                1600                       2400
    WARD                                 1250                       3650
    JONES                                2975                       6625
    MARTIN                               1250                       7875
    BLAKE                                2850                      10725
    CLARK                                2450                      13175
    SCOTT                                3000                      16175
    KING                                 5000                      21175
    TURNER                               1500                      22675
    ADAMS                                1100                      23775
    JAMES                                 950                      24725
    FORD                                 3000                      27725
    MILLER                               1300                      29025
    14 rows selected.Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • How can I optimize this CAN program?

    I currently have the program called "GCS message.vi". It reads CAN messages and has the ability to alter them. It then resends the CAN messages out. "GCS message stim and monitor.vi" runs with this, but does the opposite. It sends out messages, and then monitors the ouput of "GCS message.vi". This program runs at only a couple of Hertz, but when all the CAN programming is eliminated, the program runs extremely fast. And if all the excess programming is eliminated leaving only sending and receiving of CAN messages, then the program runs extremely fast again. I'm wondering what aspect of the program is slowing everything down and how I could program around it.
    Notes:
    The stim and monitor should be run first, and the start button on the VI should be pressed once the message vi is running.
    To check the execution speed, put a value in the "Inject Selected Errors" box and click the button next to it. It will countdown to zero.
    Attachments:
    GCS.zip ‏400 KB

    Hello,
    As you have noted, your problem seems to be purely LabVIEW. When you run with just your CAN commands, things are fast. One thing to note in your program (looking in CGS message.vi) is the large number of property node accesses; each access to a property node will cause a thread swap to the user interface (in the event that multiple threads have been spawned, which appears likely since you define multiple parallel tasks). Given that you have a relativel complicated GUI there, this may indeed affect performance significantly. In general, you should (if at all possible) use wires to dictate value assignment, and if necessary you may try changing the some of your property nodes (the ones that simply change the value of a control or indicator) to local variables to prevent the thread swapping. Now, this may not be the only performance enhancement to make; I would strongly recommend reading the following document to help get a better idea for how to find and correct memory and time performance issues in LabVIEW:
    http://zone.ni.com/devzone/conceptd.nsf/webmain/732CEC772AA4FBE586256A37005541D3
    Best Regards,
    JLS
    Best,
    JLS
    Sixclear

Maybe you are looking for