Order By Clause - Slows performance

On 10.2 when adding an order by clause to a query affects performance that returns 6 rows of data.
Before:
select distinct col1
from table1
Cost: 3,000
Execution Time: less than a second
Chooses: Bitmap Index Fast Full Scan Index (BitMap)
After:
select distinct col1
from table1
order by col1
Cost: 14,000
Execution time: 90 seconds
Chooses: Full TableScan
Any ideas as to why the order by causes the slow down ?
Thanks,

Venzi wrote:
Now you add the order by clause to it and Oracle has now to do a sort on it. It can't sort on the BITMAP index in that case so it has to go to the table. It is possible for Oracle to do the order by through the bitmap index - the reason it doesn't is probably down to arithmetic. (The situation is made a little messier by the fact that the table and index have been parallel enabled). Here's a plan from 10.2.0.3 showing the "order by" query running through the bitmap index:
| Id  | Operation                          | Name     | Rows  | Bytes | Cost  |    TQ  |IN-OUT| PQ Distrib |
|   0 | SELECT STATEMENT                   |          |     6 |    18 |   356 |        |      |            |
|   1 |  PX COORDINATOR                    |          |       |       |       |        |      |            |
|   2 |   PX SEND QC (ORDER)               | :TQ10001 |     6 |    18 |   356 |  Q1,01 | P->S | QC (ORDER) |
|   3 |    SORT GROUP BY                   |          |     6 |    18 |   356 |  Q1,01 | PCWP |            |
|   4 |     PX RECEIVE                     |          |  2000K|  5859K|    63 |  Q1,01 | PCWP |            |
|   5 |      PX SEND RANGE                 | :TQ10000 |  2000K|  5859K|    63 |  Q1,00 | P->P | RANGE      |
|   6 |       PX BLOCK ITERATOR            |          |  2000K|  5859K|    63 |  Q1,00 | PCWC |            |
|   7 |        BITMAP CONVERSION TO ROWIDS |          |  2000K|  5859K|    63 |  Q1,00 | PCWP |            |
|   8 |         BITMAP INDEX FAST FULL SCAN| T1_B1    |       |       |       |  Q1,00 | PCWP |            |
------------------------------------------------------------------------------------------------------------Note how the optimizer can recognise that the "group by" operation will allow it to avoid an explicit "order by" operation, and uses the "(ORDER)" distribution to pass the data to the Query Coordinator to enforce correct ordering.
Running up a test case with a couple of million rows, it looks like the underlying problem the OP has is that the CBO bypasses a few of the execution options in this particular case when parallel execution is possible. (I had to hint this plan - the default plan was a serial full scan of the index that allowed the optimizer to bypass the "sort order" because of a "sort unique", but the cost was much higher than this parallel plan - see below).
| Id  | Operation               | Name  | Rows  | Bytes | Cost  |
|   0 | SELECT STATEMENT        |       |     6 |    18 |  2269 |
|   1 |  SORT UNIQUE NOSORT     |       |     6 |    18 |  2269 |
|   2 |   BITMAP INDEX FULL SCAN| T1_B1 |  2000K|  5859K|   278 |
-----------------------------------------------------------------Regards
Jonathan Lewis
http://jonathanlewis.wordpress.com
http://www.jlcomp.demon.co.uk
To post code, statspack/AWR report, execution plans or trace files, start and end the section with the tag {noformat}{noformat} (lowercase, curly brackets, no spaces) so that the text appears in fixed format.
There is a +"Preview"+ tab at the top of the text entry panel. Use this to check what your message will look like before you post the message. If it looks a complete mess you're unlikely to get a response. (Click on the +"Plain text"+ tab if you want to edit the text to tidy it up.)
+"I believe in evidence. I believe in observation, measurement, and reasoning, confirmed by independent observers. I'll believe anything, no matter how wild and ridiculous, if there is evidence for it. The wilder and more ridiculous something is, however, the firmer and more solid the evidence will have to be."+
Isaac Asimov                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • Order by clause slows down my query

    Greetings!!!
    I need an advice on how can i make  the query below run faster  preserving the order by fields.I have only 8000 records but it gives the output in 21.8 sec.
    SELECT
    ORDER_ITEM.OI_ITEM_ID,
    ORDER_ITEM.OI_SEQ,
    GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_CODE,
    ORDER_ITEM.OI_ITEM_DESC,
    ORDER_ITEM.OI_ITEM_SIZE_ID,
    ORDER_ITEM.OI_QTY,
    (VIEW_SUM_ITEM_SHIPMENT_QTY.TOTAL_QTY_SHIPPED-ORDER_ITEM.OI_QTY) BALANCE_SHIP_QTY,
    ORDER_ITEM.OI_DELVERY_DATE,
    ORDER_ITEM.OI_ENTRY_DATE,
    (round((select sysdate from sys.dual)-
    ORDER_ITEM.OI_ENTRY_DATE)) no_days_passed,
    ORDER_ITEM.OI_SALES_CONTRACT_ITEM_FLAG,
    ORDER_ITEM.OI_ITEM_DESCC,
    ORDER_ITEM.OI_DESIGNER_ID OI_DESIGNER_ID,
    ORDER_ITEM.OI_FABRIC_GROUP_CODE,
    ORDER_ITEM.OI_UM_ID,
    ORDER_ITEM.OI_GROUP_CODE,
    ORDER_ITEM.OI_GENRE_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_PART_ID,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    ORDER_ITEM.OI_ITEM_STATUS_ID,
    ORDER_ITEM.OI_BARCODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    SIZE_TEMPLATE.ST_COL1,
    SIZE_TEMPLATE.ST_COL2,
    SIZE_TEMPLATE.ST_COL3,
    SIZE_TEMPLATE.ST_COL4,
    SIZE_TEMPLATE.ST_COL5,
    SIZE_TEMPLATE.ST_COL6,
    SIZE_TEMPLATE.ST_COL7,
    SIZE_TEMPLATE.ST_COL8,
    SIZE_TEMPLATE.ST_COL9,
    SIZE_TEMPLATE.ST_COL10,
    SIZE_TEMPLATE.ST_COL11,
    SIZE_TEMPLATE.ST_COL12,
    STAFF.S_STAFFNAMEC,
    STAFF.S_STAFFCODE,
    STAFF.S_STAFFNAMEE,
    UNIT_MEASUREMENT.UM_UNIT_CODE, ITEM_GENRE.IG_DESC_ENG,
    ORDER_ITEM_STATUS.OIS_STATUS_DESC,
    MIN(VIEW_ORDER_ITEM_PART.OIP_GROUP_CODE)MIN_OIP_GROUP_CODE,
    STRAGG( DISTINCT VIEW_ORDER_ITEM_PART.F_SHORTCODEC)STRAGG_F_SHORTCODEC,
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.S_STAFFNAMEC)STRAGG_QCNAME,
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.F_FABRIC_DESC_CHN)STRAGG_FABRIC,
    ORDER_ITEM.OI_REMARKS,
    ORDER_ITEM.OI_HSCODE,
    ORDER_ITEM.OI_CATEGORY,
    ORDER_ITEM.OI_CAT,
    ORDER_ITEM.QCS_CATEGORY_ID,
    QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_CODE,
    ORDER_ITEM.OI_ORDER_TYPE
    FROM ORDER_ITEM, SIZE_TEMPLATE, STAFF, UNIT_MEASUREMENT, ITEM_GENRE,ORDER_ITEM_STATUS,VIEW_ORDER_ITEM_PART,GEN_ORDER_NUMBER_OPERATOR,VIEW_SUM_ITEM_SHIPMENT_QTY,QUOTA_CATEGORY_STANDARD
    WHERE ((ORDER_ITEM.OI_ITEM_SIZE_ID = SIZE_TEMPLATE.ST_SIZETEMPLATE_ID(+))
    AND (ORDER_ITEM.OI_DESIGNER_ID = STAFF.S_STAFF_ID(+))
    AND (ORDER_ITEM.OI_UM_ID = UNIT_MEASUREMENT.UM_UNIT_ID(+))
    AND (ORDER_ITEM.OI_GENRE_ID = ITEM_GENRE.IG_GENRE_ID(+))
    AND (ORDER_ITEM.OI_ITEM_STATUS_ID=ORDER_ITEM_STATUS.OIS_STATUS_ID(+))
    AND (ORDER_ITEM.OI_ITEM_ID=VIEW_ORDER_ITEM_PART.OIP_ITEM_ID(+))
    AND (ORDER_ITEM.QCS_CATEGORY_ID=QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_ID(+))
    AND (ORDER_ITEM.OI_ITEM_ID=VIEW_SUM_ITEM_SHIPMENT_QTY.OI_ITEM_ID(+))
    AND (ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID = GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_OPER_ID(+)))
    GROUP BY
    ORDER_ITEM.OI_ITEM_ID,
    ORDER_ITEM.OI_SEQ,
    GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_CODE,
    ORDER_ITEM.OI_ITEM_DESC,
    ORDER_ITEM.OI_ITEM_SIZE_ID,
    ORDER_ITEM.OI_QTY,
    (VIEW_SUM_ITEM_SHIPMENT_QTY.TOTAL_QTY_SHIPPED-ORDER_ITEM.OI_QTY),
    ORDER_ITEM.OI_DELVERY_DATE,
    ORDER_ITEM.OI_ENTRY_DATE,
    ORDER_ITEM.OI_SALES_CONTRACT_ITEM_FLAG,
    ORDER_ITEM.OI_ITEM_DESCC,
    ORDER_ITEM.OI_DESIGNER_ID,
    ORDER_ITEM.OI_FABRIC_GROUP_CODE,
    ORDER_ITEM.OI_UM_ID,
    ORDER_ITEM.OI_GROUP_CODE,
    ORDER_ITEM.OI_GENRE_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_PART_ID,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    ORDER_ITEM.OI_ITEM_STATUS_ID,
    ORDER_ITEM.OI_BARCODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    SIZE_TEMPLATE.ST_COL1,
    SIZE_TEMPLATE.ST_COL2,
    SIZE_TEMPLATE.ST_COL3,
    SIZE_TEMPLATE.ST_COL4,
    SIZE_TEMPLATE.ST_COL5,
    SIZE_TEMPLATE.ST_COL6,
    SIZE_TEMPLATE.ST_COL7,
    SIZE_TEMPLATE.ST_COL8,
    SIZE_TEMPLATE.ST_COL9,
    SIZE_TEMPLATE.ST_COL10,
    SIZE_TEMPLATE.ST_COL11,
    SIZE_TEMPLATE.ST_COL12,
    STAFF.S_STAFFNAMEC,
    STAFF.S_STAFFCODE,
    STAFF.S_STAFFNAMEE,
    UNIT_MEASUREMENT.UM_UNIT_CODE, ITEM_GENRE.IG_DESC_ENG,
    ORDER_ITEM_STATUS.OIS_STATUS_DESC,
    ORDER_ITEM.OI_REMARKS,
    ORDER_ITEM.OI_HSCODE,
    ORDER_ITEM.OI_CATEGORY,
    ORDER_ITEM.OI_CAT,
    ORDER_ITEM.QCS_CATEGORY_ID,
    QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_CODE,
    ORDER_ITEM.OI_ORDER_TYPE
    ORDER BY
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_STATUS_ID ASC NULLS FIRST,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    MIN(VIEW_ORDER_ITEM_PART.OIP_GROUP_CODE),
    STRAGG( DISTINCT VIEW_ORDER_ITEM_PART.F_FABRIC_DESC_CHN),
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.F_SHORTCODEC),
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.S_STAFFNAMEC),
    ORDER_ITEM.OI_DELVERY_DATE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    ORDER_ITEM.OI_SEQ,
    ORDER_ITEM.OI_ITEM_ID
    Tnx in Advance

    Tnx Rob for the reply...
    Here's the explain plan
    Plan hash value: 3988043906
    | Id  | Operation                        | Name                       | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                 |                            |  7663 |  2207K|       |  1190   (3)| 00:00:15 |
    |   1 |  FAST DUAL                       |                            |     1 |       |       |     2   (0)| 00:00:01 |
    |   2 |   SORT ORDER BY                  |                            |  7663 |  2207K|  4728K|  1190   (3)| 00:00:15 |
    |   3 |    SORT GROUP BY                 |                            |  7663 |  2207K|  4728K|  1190   (3)| 00:00:15 |
    |*  4 |     HASH JOIN RIGHT OUTER        |                            |  7663 |  2207K|       |   212  (13)| 00:00:03 |
    |   5 |      VIEW                        | VIEW_SUM_ITEM_SHIPMENT_QTY |  4238 | 76284 |       |    17  (18)| 00:00:01 |
    |   6 |       SORT ORDER BY              |                            |  4238 | 38142 |       |    17  (18)| 00:00:01 |
    |   7 |        SORT GROUP BY             |                            |  4238 | 38142 |       |    17  (18)| 00:00:01 |
    |*  8 |         TABLE ACCESS FULL        | SHIPMENT_ITEM              |  4924 | 44316 |       |    14   (0)| 00:00:01 |
    |*  9 |      HASH JOIN RIGHT OUTER       |                            |  7663 |  2072K|       |   194  (12)| 00:00:03 |
    |  10 |       TABLE ACCESS FULL          | SIZE_TEMPLATE              |   422 | 16458 |       |     2   (0)| 00:00:01 |
    |* 11 |       HASH JOIN RIGHT OUTER      |                            |  7663 |  1781K|       |   192  (12)| 00:00:03 |
    |  12 |        TABLE ACCESS FULL         | STAFF                      |   115 |  2530 |       |     2   (0)| 00:00:01 |
    |* 13 |        HASH JOIN RIGHT OUTER     |                            |  7663 |  1616K|       |   189  (12)| 00:00:03 |
    |  14 |         TABLE ACCESS FULL        | UNIT_MEASUREMENT           |     7 |    49 |       |     2   (0)| 00:00:01 |
    |* 15 |         HASH JOIN RIGHT OUTER    |                            |  7663 |  1564K|   544K|   187  (12)| 00:00:03 |
    |  16 |          VIEW                    | VIEW_ORDER_ITEM_PART       |  7320 |   450K|       |    53  (33)| 00:00:01 |
    |* 17 |           HASH JOIN RIGHT OUTER  |                            |  7320 |   736K|       |    53  (33)| 00:00:01 |
    |  18 |            TABLE ACCESS FULL     | STAFF                      |   115 |  1610 |       |     2   (0)| 00:00:01 |
    |* 19 |            HASH JOIN RIGHT OUTER |                            |  7320 |   636K|       |    51  (34)| 00:00:01 |
    |  20 |             TABLE ACCESS FULL    | FABRIC                     |  1773 | 69147 |       |     8   (0)| 00:00:01 |
    |* 21 |             HASH JOIN RIGHT OUTER|                            |  7320 |   357K|       |    42  (39)| 00:00:01 |
    |  22 |              TABLE ACCESS FULL   | FACTORY                    |   352 |  5280 |       |     8   (0)| 00:00:01 |
    |  23 |              NESTED LOOPS OUTER  |                            |  7320 |   250K|       |    34  (48)| 00:00:01 |
    |  24 |               NESTED LOOPS OUTER |                            |  7320 |   221K|       |    29  (38)| 00:00:01 |
    |  25 |                NESTED LOOPS OUTER|                            |  7320 |   200K|       |    24  (25)| 00:00:01 |
    |  26 |                 TABLE ACCESS FULL| ORDER_ITEM_PART            |  7320 |   164K|       |    18   (0)| 00:00:01 |
    |* 27 |                 INDEX UNIQUE SCAN| PK_OI_ITEM_ID              |     1 |     5 |       |     0   (0)| 00:00:01 |
    |* 28 |                INDEX UNIQUE SCAN | PK_UNIT_MEASUREMENT        |     1 |     3 |       |     0   (0)| 00:00:01 |
    |* 29 |               INDEX UNIQUE SCAN  | PK_F_FACTORY_ID            |     1 |     4 |       |     0   (0)| 00:00:01 |
    |* 30 |          HASH JOIN RIGHT OUTER   |                            |  7040 |  1003K|       |    41   (5)| 00:00:01 |
    |  31 |           TABLE ACCESS FULL      | ITEM_GENRE                 |     5 |    35 |       |     2   (0)| 00:00:01 |
    |* 32 |           HASH JOIN RIGHT OUTER  |                            |  7040 |   955K|       |    39   (6)| 00:00:01 |
    |  33 |            TABLE ACCESS FULL     | ORDER_ITEM_STATUS          |     5 |    70 |       |     2   (0)| 00:00:01 |
    |* 34 |            HASH JOIN RIGHT OUTER |                            |  7040 |   859K|       |    36   (3)| 00:00:01 |
    |  35 |             TABLE ACCESS FULL    | GEN_ORDER_NUMBER_OPERATOR  |   360 |  2880 |       |     2   (0)| 00:00:01 |
    |* 36 |             HASH JOIN RIGHT OUTER|                            |  7040 |   804K|       |    34   (3)| 00:00:01 |
    |  37 |              TABLE ACCESS FULL   | QUOTA_CATEGORY_STANDARD    |    60 |   480 |       |     2   (0)| 00:00:01 |
    |  38 |              TABLE ACCESS FULL   | ORDER_ITEM                 |  7040 |   749K|       |    31   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       4 - access("ORDER_ITEM"."OI_ITEM_ID"="VIEW_SUM_ITEM_SHIPMENT_QTY"."OI_ITEM_ID"(+))
       8 - filter("SHIPMENT_ITEM"."OI_ITEM_ID" IS NOT NULL)
       9 - access("ORDER_ITEM"."OI_ITEM_SIZE_ID"="SIZE_TEMPLATE"."ST_SIZETEMPLATE_ID"(+))
      11 - access("ORDER_ITEM"."OI_DESIGNER_ID"="STAFF"."S_STAFF_ID"(+))
      13 - access("ORDER_ITEM"."OI_UM_ID"="UNIT_MEASUREMENT"."UM_UNIT_ID"(+))
      15 - access("ORDER_ITEM"."OI_ITEM_ID"="VIEW_ORDER_ITEM_PART"."OIP_ITEM_ID"(+))
      17 - access("ORDER_ITEM_PART"."OIP_QC_ID"="STAFF"."S_STAFF_ID"(+))
      19 - access("ORDER_ITEM_PART"."OIP_FABRIC_ID"="FABRIC"."F_FABRIC_ID"(+))
      21 - access("ORDER_ITEM_PART"."OIP_FACTORY_ID"="FACTORY"."F_FACTORY_ID"(+))
      27 - access("ORDER_ITEM_PART"."OIP_ITEM_ID"="ORDER_ITEM"."OI_ITEM_ID"(+))
      28 - access("ORDER_ITEM_PART"."OIP_UNIT"="UNIT_MEASUREMENT"."UM_UNIT_ID"(+))
      29 - access("ORDER_ITEM_PART"."OIP_ALT_FACTORY_ID"="FACTORY_A1"."F_FACTORY_ID"(+))
      30 - access("ORDER_ITEM"."OI_GENRE_ID"="ITEM_GENRE"."IG_GENRE_ID"(+))
      32 - access("ORDER_ITEM"."OI_ITEM_STATUS_ID"="ORDER_ITEM_STATUS"."OIS_STATUS_ID"(+))
      34 - access("ORDER_ITEM"."OI_ORDER_NUMBER_OPER_ID"="GEN_ORDER_NUMBER_OPERATOR"."GONO_ORDER_NUMBER_OPER_ID"(+)
      36 - access("ORDER_ITEM"."QCS_CATEGORY_ID"="QUOTA_CATEGORY_STANDARD"."QCS_CATEGORY_ID"(+))The output from tkprof
    TKPROF: Release 10.1.0.2.0 - Production on Wed Aug 1 18:47:32 2007
    Copyright (c) 1982, 2004, Oracle.  All rights reserved.
    Trace file: erpdada_ora_3464.trc
    Sort options: prsela  exeela  fchela 
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    SELECT
    ORDER_ITEM.OI_ITEM_ID,
    ORDER_ITEM.OI_SEQ,
    GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_CODE,
    ORDER_ITEM.OI_ITEM_DESC,
    ORDER_ITEM.OI_ITEM_SIZE_ID,
    ORDER_ITEM.OI_QTY,
    (VIEW_SUM_ITEM_SHIPMENT_QTY.TOTAL_QTY_SHIPPED-ORDER_ITEM.OI_QTY) BALANCE_SHIP_QTY,
    ORDER_ITEM.OI_DELVERY_DATE,
    ORDER_ITEM.OI_ENTRY_DATE,
    (round((select sysdate from sys.dual)-
    ORDER_ITEM.OI_ENTRY_DATE)) no_days_passed,
    ORDER_ITEM.OI_SALES_CONTRACT_ITEM_FLAG,
    ORDER_ITEM.OI_ITEM_DESCC,
    ORDER_ITEM.OI_DESIGNER_ID OI_DESIGNER_ID,
    ORDER_ITEM.OI_FABRIC_GROUP_CODE,
    ORDER_ITEM.OI_UM_ID,
    ORDER_ITEM.OI_GROUP_CODE,
    ORDER_ITEM.OI_GENRE_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_PART_ID,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    ORDER_ITEM.OI_ITEM_STATUS_ID,
    ORDER_ITEM.OI_BARCODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    SIZE_TEMPLATE.ST_COL1,
    SIZE_TEMPLATE.ST_COL2,
    SIZE_TEMPLATE.ST_COL3,
    SIZE_TEMPLATE.ST_COL4,
    SIZE_TEMPLATE.ST_COL5,
    SIZE_TEMPLATE.ST_COL6,
    SIZE_TEMPLATE.ST_COL7,
    SIZE_TEMPLATE.ST_COL8,
    SIZE_TEMPLATE.ST_COL9,
    SIZE_TEMPLATE.ST_COL10,
    SIZE_TEMPLATE.ST_COL11,
    SIZE_TEMPLATE.ST_COL12,
    STAFF.S_STAFFNAMEC,
    STAFF.S_STAFFCODE,
    STAFF.S_STAFFNAMEE,
    UNIT_MEASUREMENT.UM_UNIT_CODE, ITEM_GENRE.IG_DESC_ENG,
    ORDER_ITEM_STATUS.OIS_STATUS_DESC,
    MIN(VIEW_ORDER_ITEM_PART.OIP_GROUP_CODE)MIN_OIP_GROUP_CODE,
    STRAGG( DISTINCT VIEW_ORDER_ITEM_PART.F_SHORTCODEC)STRAGG_F_SHORTCODEC,
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.S_STAFFNAMEC)STRAGG_QCNAME,
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.F_FABRIC_DESC_CHN)STRAGG_FABRIC,
    ORDER_ITEM.OI_REMARKS,
    ORDER_ITEM.OI_HSCODE,
    ORDER_ITEM.OI_CATEGORY,
    ORDER_ITEM.OI_CAT,
    ORDER_ITEM.QCS_CATEGORY_ID,
    QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_CODE,
    ORDER_ITEM.OI_ORDER_TYPE
    FROM ORDER_ITEM, SIZE_TEMPLATE, STAFF, UNIT_MEASUREMENT, ITEM_GENRE,ORDER_ITEM_STATUS,VIEW_ORDER_ITEM_PART,GEN_ORDER_NUMBER_OPERATOR,VIEW_SUM_ITEM_SHIPMENT_QTY,QUOTA_CATEGORY_STANDARD
    WHERE ((ORDER_ITEM.OI_ITEM_SIZE_ID = SIZE_TEMPLATE.ST_SIZETEMPLATE_ID(+))
    AND (ORDER_ITEM.OI_DESIGNER_ID = STAFF.S_STAFF_ID(+))
    AND (ORDER_ITEM.OI_UM_ID = UNIT_MEASUREMENT.UM_UNIT_ID(+))
    AND (ORDER_ITEM.OI_GENRE_ID = ITEM_GENRE.IG_GENRE_ID(+))
    AND (ORDER_ITEM.OI_ITEM_STATUS_ID=ORDER_ITEM_STATUS.OIS_STATUS_ID(+))
    AND (ORDER_ITEM.OI_ITEM_ID=VIEW_ORDER_ITEM_PART.OIP_ITEM_ID(+))
    AND (ORDER_ITEM.QCS_CATEGORY_ID=QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_ID(+))
    AND (ORDER_ITEM.OI_ITEM_ID=VIEW_SUM_ITEM_SHIPMENT_QTY.OI_ITEM_ID(+))
    AND (ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID = GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_OPER_ID(+)))
    GROUP BY
    ORDER_ITEM.OI_ITEM_ID,
    ORDER_ITEM.OI_SEQ,
    GEN_ORDER_NUMBER_OPERATOR.GONO_ORDER_NUMBER_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_CODE,
    ORDER_ITEM.OI_ITEM_DESC,
    ORDER_ITEM.OI_ITEM_SIZE_ID,
    ORDER_ITEM.OI_QTY,
    (VIEW_SUM_ITEM_SHIPMENT_QTY.TOTAL_QTY_SHIPPED-ORDER_ITEM.OI_QTY),
    ORDER_ITEM.OI_DELVERY_DATE,
    ORDER_ITEM.OI_ENTRY_DATE,
    ORDER_ITEM.OI_SALES_CONTRACT_ITEM_FLAG,
    ORDER_ITEM.OI_ITEM_DESCC,
    ORDER_ITEM.OI_DESIGNER_ID,
    ORDER_ITEM.OI_FABRIC_GROUP_CODE,
    ORDER_ITEM.OI_UM_ID,
    ORDER_ITEM.OI_GROUP_CODE,
    ORDER_ITEM.OI_GENRE_ID,
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_PART_ID,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    ORDER_ITEM.OI_ITEM_STATUS_ID,
    ORDER_ITEM.OI_BARCODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    SIZE_TEMPLATE.ST_COL1,
    SIZE_TEMPLATE.ST_COL2,
    SIZE_TEMPLATE.ST_COL3,
    SIZE_TEMPLATE.ST_COL4,
    SIZE_TEMPLATE.ST_COL5,
    SIZE_TEMPLATE.ST_COL6,
    SIZE_TEMPLATE.ST_COL7,
    SIZE_TEMPLATE.ST_COL8,
    SIZE_TEMPLATE.ST_COL9,
    SIZE_TEMPLATE.ST_COL10,
    SIZE_TEMPLATE.ST_COL11,
    SIZE_TEMPLATE.ST_COL12,
    STAFF.S_STAFFNAMEC,
    STAFF.S_STAFFCODE,
    STAFF.S_STAFFNAMEE,
    UNIT_MEASUREMENT.UM_UNIT_CODE, ITEM_GENRE.IG_DESC_ENG,
    ORDER_ITEM_STATUS.OIS_STATUS_DESC,
    ORDER_ITEM.OI_REMARKS,
    ORDER_ITEM.OI_HSCODE,
    ORDER_ITEM.OI_CATEGORY,
    ORDER_ITEM.OI_CAT,
    ORDER_ITEM.QCS_CATEGORY_ID,
    QUOTA_CATEGORY_STANDARD.QCS_CATEGORY_CODE,
    ORDER_ITEM.OI_ORDER_TYPE
    ORDER  BY
    ORDER_ITEM.OI_ORDER_NUMBER_OPER_ID,
    ORDER_ITEM.OI_ITEM_STATUS_ID ASC NULLS FIRST,
    ORDER_ITEM.OI_THEME_GROUP_CODE,
    ORDER_ITEM.OI_THEME_DESC,
    MIN(VIEW_ORDER_ITEM_PART.OIP_GROUP_CODE),
    STRAGG( DISTINCT VIEW_ORDER_ITEM_PART.F_FABRIC_DESC_CHN),
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.F_SHORTCODEC),
    STRAGG(DISTINCT VIEW_ORDER_ITEM_PART.S_STAFFNAMEC),
    ORDER_ITEM.OI_DELVERY_DATE,
    SIZE_TEMPLATE.ST_SIZETEMPLATECODE,
    SIZE_TEMPLATE.ST_SIZETEMPLATEDESC,
    ORDER_ITEM.OI_SEQ,
    ORDER_ITEM.OI_ITEM_ID
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      3.99       4.20          0        744          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        5     14.03      18.13       2813       7811         63          50
    total        8     18.02      22.34       2813       8555         63          50
    Misses in library cache during parse: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 64 
    Rows     Row Source Operation
          0  SORT ORDER BY (cr=0 pr=0 pw=0 time=0 us)
          0   SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us)
          0    HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0     VIEW  (cr=0 pr=0 pw=0 time=0 us)
          0      SORT ORDER BY (cr=0 pr=0 pw=0 time=0 us)
          0       SORT GROUP BY (cr=0 pr=0 pw=0 time=0 us)
          0        TABLE ACCESS FULL SHIPMENT_ITEM (cr=0 pr=0 pw=0 time=0 us)
          0     HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0      TABLE ACCESS FULL SIZE_TEMPLATE (cr=0 pr=0 pw=0 time=0 us)
          0      HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0       TABLE ACCESS FULL STAFF (cr=0 pr=0 pw=0 time=0 us)
          0       HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0        TABLE ACCESS FULL UNIT_MEASUREMENT (cr=0 pr=0 pw=0 time=0 us)
          0        HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0         VIEW  (cr=0 pr=0 pw=0 time=0 us)
          0          HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0           TABLE ACCESS FULL STAFF (cr=0 pr=0 pw=0 time=0 us)
          0           HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0            TABLE ACCESS FULL FABRIC (cr=0 pr=0 pw=0 time=0 us)
          0            HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0             TABLE ACCESS FULL FACTORY (cr=0 pr=0 pw=0 time=0 us)
          0             NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us)
          0              NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us)
          0               NESTED LOOPS OUTER (cr=0 pr=0 pw=0 time=0 us)
          0                TABLE ACCESS FULL ORDER_ITEM_PART (cr=0 pr=0 pw=0 time=0 us)
          0                INDEX UNIQUE SCAN PK_OI_ITEM_ID (cr=0 pr=0 pw=0 time=0 us)(object id 50551)
          0               INDEX UNIQUE SCAN PK_UNIT_MEASUREMENT (cr=0 pr=0 pw=0 time=0 us)(object id 50324)
          0              INDEX UNIQUE SCAN PK_F_FACTORY_ID (cr=0 pr=0 pw=0 time=0 us)(object id 51087)
          0         HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0          TABLE ACCESS FULL ITEM_GENRE (cr=0 pr=0 pw=0 time=0 us)
          0          HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0           TABLE ACCESS FULL ORDER_ITEM_STATUS (cr=0 pr=0 pw=0 time=0 us)
          0           HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0            TABLE ACCESS FULL GEN_ORDER_NUMBER_OPERATOR (cr=0 pr=0 pw=0 time=0 us)
          0            HASH JOIN RIGHT OUTER (cr=0 pr=0 pw=0 time=0 us)
          0             TABLE ACCESS FULL QUOTA_CATEGORY_STANDARD (cr=0 pr=0 pw=0 time=0 us)
          0             TABLE ACCESS FULL ORDER_ITEM (cr=0 pr=0 pw=0 time=0 us)
    SELECT COLUMN_VALUE
    FROM
    TABLE(:B1 ) ORDER BY 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute  21273      3.27       3.62          0          0          0           0
    Fetch    21273      1.40       1.36          0          0          0       20844
    total    42547      4.67       4.99          0          0          0       20844
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 64     (recursive depth: 1)
    Rows     Row Source Operation
      20844  SORT ORDER BY (cr=0 pr=0 pw=0 time=1493588 us)
      20844   COLLECTION ITERATOR PICKLER FETCH (cr=0 pr=0 pw=0 time=350669 us)
    alter session set sql_trace true
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 64 
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      3.99       4.20          0        744          0           0
    Execute      3      0.00       0.00          0          0          0           0
    Fetch        5     14.03      18.13       2813       7811         63          50
    total        9     18.02      22.34       2813       8555         63          50
    Misses in library cache during parse: 1
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        4      0.00       0.00          0          0          0           0
    Execute  21276      3.27       3.62          0          0          0           0
    Fetch    21276      1.40       1.36          0          7          0       20847
    total    42556      4.67       4.99          0          7          0       20847
    Misses in library cache during parse: 0
        3  user  SQL statements in session.
        3  internal SQL statements in session.
        6  SQL statements in session.
    Trace file: erpdada_ora_3464.trc
    Trace file compatibility: 10.01.00
    Sort options: prsela  exeela  fchela 
           1  session in tracefile.
           3  user  SQL statements in trace file.
           3  internal SQL statements in trace file.
           6  SQL statements in trace file.
           5  unique SQL statements in trace file.
       42783  lines in trace file.
          37  elapsed seconds in trace file.
    Im sorry for giving trouble guys.....Awaiting for reply...Tnx in advance

  • Order by Clause is slow

    Guys,
    I have a table of 80,000 records.If i select * from this table need 0.04 seconds.If I add order by clause it become very slow 30 sec.
    Order by clause is on the primary key.Also i increased the size of temp tablespace.
    Kindly assist

    In Forms, LOV's are meant for a small set of values.
    For a table containing 80,000 records you need to develop a small selection form, i.e. a separate form in which you can search for values and select one value. Details for this can be acquired in the Oracle*Forms Forum. A form will typically fetch only a few rows and is therefore more suited in this case. Be sure to check the block properties "Query Array Size", "Number of Records Buffered" and "Query All Records".
    At my shop we use a standard of approximately 20 values. Below this number a LOV can be used and above a select form is recommended.
    Regards,
    Rob.

  • Performance issue-order by clause

    hi all,
    i hava a Query it will take time to exec 6 sec....
    i want to reduce it less 1 sec
    i found the problem,that Query it will take more time to Order BY clause...
    how to improve the performance ?

    Try it with an index. Or give us more information about the query.
    How did you find out that it takes more time with the order? Usually ordering does takes time but not so much. be aware that when you add an order by clause then any tool can start showing you the records only after the query is finished. If you have no order by, you can see some results already even if the query is not finished yet.
    Make sure you compare the total running time of the query, not only how fast you see the first records.

  • Slow SQL output when table alias is NOT used in order by clause

    Hi guys,
    My query is based on Oracle 9208
    I have a table TAB1 with 68000 records with transaction_id as the primary key in this table (unique index).
    I have another TAB2 with the same number of records again with transaction_id in this table (foreign key to above).
    I have the below query that gets executed via an application:-
    SELECT TO_CHAR(V1.TRANSACTION_ID), V1.POLICY_ID, V1.REQUEST_TYPE
    FROM <VIEW> V1 WHERE V1.CERT_SERIAL_NUM=56192 AND
    (V1.AUTH_GROUP_ID=0 OR V1.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
    BY TRANSACTION_ID ASC
    The above view V1 is created as below:-
    CREATE OR REPLACE FORCE VIEW "V1"
    ("TRANSACTION_ID",
    "PARENT_TRANSACTION_ID",
    "CA_DN_ID",
    "AUTH_GROUP_ID",
    "POLICY_ID",
    "REQUEST_TYPE",
    "REQUEST_STATUS",
    "EE_DN_HASH",
    "EE_DN",
    "EE_EMAIL_HASH",
    "EE_EMAIL",
    "KEY_USAGE",
    "SMART_CARD_SERIAL",
    "CERT_TYPE",
    "CERT_SERIAL_NUM",
    "CERT_INDEX",
    "RENEWAL_FLAG",
    "ARCHIVE_FLAG",
    "TIME_RECEIVED",
    "DOWNLOADED",
    "REQUEST_DATA",
    "ACTION",
    "STEP_NUM")
    AS
    SELECT
    T1.transaction_id,
    T1.parent_transaction_id,
    T1.ca_dn_id,
    V2.auth_group_id,
    V2.policy_id,
    T1.request_type,
    T1.request_status,
    T2.ee_dn_hash,
    T2.ee_dn,
    T2.ee_email_hash,
    T2.ee_email,
    T2.key_usage,
    T2.smart_card_serial,
    T2.cert_type,
    T2.cert_serial_num,
    T2.cert_index,
    T2.renewal_flag,
    T2.archive_flag,
    T1.time_received,
    T1.downloaded,
    T1.request_data,
    V2.action,
    V2.step_num
    FROM TAB1
    <ANOTHER VIEW> V2,
    TAB2 T1,
    TAB2 T2
    WHERE
    T1.transaction_id = T2.transaction_id
    AND
    V2.policy_id = T1.policy_id
    order by transaction_id;
    The query at the top runs within milliseconds if the VIEW is created as :-
    order by t2.transaction_id
    But without the alias "t2" in the order by, the query takes about 1 1/2 minutes
    Can you tell me why? I thought if you ordering by primary key (lesser number of values compared to foreign key values), the query should be faster..no?
    Thanks in advance

    Thanks for keeping up with this issue Hemant.
    Here are the plans for each case.
    I would be very interested in how you'd recognize which plan is the best and what are the derivatives.
    I don't much (or rather anything!) what is 'card' values, 'cost' values etc which I believe are used to decide the best plan of the lot.
    Thanks again
    Note TAB1 and TAB2 are from view definition posted initially
    1) Execution Plan for VIEW1 <<-- With ORDER BY" clause but no table ailas (order by transaction_id)
    SQL> EXPLAIN PLAN FOR SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
    2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=24293 AND
    3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
    4 BY TRANSACTION_ID ASC
    5 /
    Explained.
    Elapsed: 00:00:01.00
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 3 | 195 | 17 |
    |* 1 | COUNT STOPKEY | | | | |
    | 2 | VIEW | VIEW1 | 17 | 1105 | 17 |
    |* 3 | SORT ORDER BY STOPKEY | | 17 | 38573 | 17 |
    | 4 | NESTED LOOPS | | 17 | 38573 | 10 |
    | 5 | MERGE JOIN CARTESIAN | | 1 | 167 | 9 |
    | 6 | VIEW | VIEW2 | 1 | 52 | 8 |
    | 7 | SORT UNIQUE | | 1 | 156 | 8 |
    | 8 | NESTED LOOPS | | 1 | 156 | 6 |
    | 9 | NESTED LOOPS | | 1 | 143 | 6 |
    | 10 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
    |* 11 | HASH JOIN | | 1 | 104 | 5 |
    | 12 | NESTED LOOPS | | 1 | 52 | 2 |
    |* 13 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
    |* 14 | INDEX UNIQUE SCAN | (PK_TAB4) | 1 | 13 | |
    | 15 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
    | 16 | VIEW PUSHED PREDICATE | View3 | 1 | 13 | |
    | 17 | NESTED LOOPS | | 1 | 52 | 2 |
    | 18 | NESTED LOOPS | | 1 | 39 | 2 |
    |* 19 | INDEX UNIQUE SCAN | (PK_TAB6) | 1 | 13 | 1 |
    |* 20 | INDEX RANGE SCAN | (PK_TAB7) | 1 | 26 | 1 |
    |* 21 | INDEX UNIQUE SCAN | (PK_TAB8) | 1 | 13 | |
    | 22 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
    |* 23 | INDEX UNIQUE SCAN | (PK_TAB9) | 1 | | |
    |* 24 | INDEX UNIQUE SCAN | (PK_TAB10)| 1 | 13 | |
    | 25 | BUFFER SORT | | 1 | 115 | 9 |
    | 26 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 115 | 1 |
    |* 27 | INDEX RANGE SCAN | (TAB2_IDX2)| 1 | | |
    |* 28 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 25224 | 1 |
    |* 29 | INDEX UNIQUE SCAN | (PK_TAB1) | 1 | | |
    Predicate Information (identified by operation id):
    1 - filter(ROWNUM<=3)
    3 - filter(ROWNUM<=3)
    11 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
    13 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
    14 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
    19 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
    20 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
    21 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
    23 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
    24 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
    27 - access("TAB2"."CERT_SERIAL_NUM"=24293)
    28 - filter("View2"."POLICY_ID"="TAB1"."POLICY_ID")
    29 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
    Note: cpu costing is off
    54 rows selected.
    Elapsed: 00:00:01.81
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
    Statistics
    39 recursive calls
    0 db block gets
    629 consistent gets
    0 physical reads
    104 redo size
    5169 bytes sent via SQL*Net to client
    405 bytes received via SQL*Net from client
    5 SQL*Net roundtrips to/from client
    31 sorts (memory)
    0 sorts (disk)
    54 rows processed
    2) Execution Plan for VIEW1 <<-- With ORDER BY" clause and table alias (order by TAB2.transaction_id)
    SQL> explain plan for SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
    2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=30003 AND
    3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
    4 BY TRANSACTION_ID ASC
    5 /
    Explained.
    Elapsed: 00:00:10.20
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 3 | 195 | 14 |
    | 1 | SORT ORDER BY | | 3 | 195 | 14 |
    |* 2 | COUNT STOPKEY | | | | |
    | 3 | VIEW | VIEW1 | 17 | 1105 | 13 |
    | 4 | NESTED LOOPS | | 17 | 38573 | 13 |
    | 5 | MERGE JOIN CARTESIAN | | 1 | 167 | 12 |
    |* 6 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 115 | 4 |
    | 7 | INDEX FULL SCAN | (TAB2_IDX) | 94 | | 1 |
    | 8 | BUFFER SORT | | 1 | 52 | 8 |
    | 9 | VIEW | VIEW2 | 1 | 52 | 8 |
    | 10 | SORT UNIQUE | | 1 | 156 | 8 |
    | 11 | NESTED LOOPS | | 1 | 156 | 6 |
    | 12 | NESTED LOOPS | | 1 | 143 | 6 |
    | 13 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
    |* 14 | HASH JOIN | | 1 | 104 | 5 |
    | 15 | NESTED LOOPS | | 1 | 52 | 2 |
    |* 16 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
    |* 17 | INDEX UNIQUE SCAN | (PK_TAB4) | 1 | 13 | |
    | 18 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
    | 19 | VIEW PUSHED PREDICATE | View3 | 1 | 13 | |
    | 20 | NESTED LOOPS | | 1 | 52 | 2 |
    | 21 | NESTED LOOPS | | 1 | 39 | 2 |
    |* 22 | INDEX UNIQUE SCAN | (PK_TAB6) | 1 | 13 | 1 |
    |* 23 | INDEX RANGE SCAN | (PK_TAB7) | 1 | 26 | 1 |
    |* 24 | INDEX UNIQUE SCAN | (PK_TAB8) | 1 | 13 | |
    | 25 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
    |* 26 | INDEX UNIQUE SCAN | (PK_TAB9) | 1 | | |
    |* 27 | INDEX UNIQUE SCAN | (PK_TAB10) | 1 | 13 | |
    |* 28 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 25224 | 1 |
    |* 29 | INDEX UNIQUE SCAN | (PK_TAB1) | 1 | | |
    Predicate Information (identified by operation id):
    2 - filter(ROWNUM<=3)
    6 - filter("TAB2"."CERT_SERIAL_NUM"=30003)
    14 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
    16 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
    17 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
    22 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
    23 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
    24 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
    26 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
    27 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
    28 - filter("VIEW2"."POLICY_ID"="TAB1"."POLICY_ID")
    29 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
    Note: cpu costing is off
    53 rows selected.
    Elapsed: 00:00:08.29
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
    Statistics
    1079 recursive calls
    0 db block gets
    597 consistent gets
    21 physical reads
    0 redo size
    5177 bytes sent via SQL*Net to client
    405 bytes received via SQL*Net from client
    5 SQL*Net roundtrips to/from client
    63 sorts (memory)
    0 sorts (disk)
    53 rows processed
    3) Execution Plan for VIEW1 <<-- Without any "ORDER BY" clause
    SQL> explain plan for SELECT TO_CHAR(QT.TRANSACTION_ID), QT.POLICY_ID, QT.REQUEST_TYPE
    2 FROM <VIEW1> QT WHERE QT.CERT_SERIAL_NUM=30003 AND
    3 (QT.AUTH_GROUP_ID=0 OR QT.AUTH_GROUP_ID=1) AND ROWNUM <= 3 ORDER
    4 BY TRANSACTION_ID ASC
    5 /
    Explained.
    Elapsed: 00:00:10.20
    SQL> select * from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id | Operation | Name | Rows | Bytes | Cost |
    | 0 | SELECT STATEMENT | | 3 | 213 | 11 |
    | 1 | SORT ORDER BY | | 3 | 213 | 11 |
    |* 2 | COUNT STOPKEY | | | | |
    | 3 | NESTED LOOPS | | 17 | 1207 | 10 |
    | 4 | MERGE JOIN CARTESIAN | | 1 | 32 | 9 |
    | 5 | VIEW | VIEW2 | 1 | 26 | 8 |
    | 6 | SORT UNIQUE | | 1 | 156 | 8 |
    | 7 | NESTED LOOPS | | 1 | 156 | 6 |
    | 8 | NESTED LOOPS | | 1 | 143 | 6 |
    | 9 | NESTED LOOPS OUTER | | 1 | 117 | 5 |
    |* 10 | HASH JOIN | | 1 | 104 | 5 |
    | 11 | NESTED LOOPS | | 1 | 52 | 2 |
    |* 12 | TABLE ACCESS FULL | TAB3 | 1 | 39 | 2 |
    |* 13 | INDEX UNIQUE SCAN | PK_TAB4 | 1 | 13 | |
    | 14 | TABLE ACCESS FULL | TAB5 | 82 | 4264 | 2 |
    | 15 | VIEW PUSHED PREDICATE | VIEW3 | 1 | 13 | |
    | 16 | NESTED LOOPS | | 1 | 52 | 2 |
    | 17 | NESTED LOOPS | | 1 | 39 | 2 |
    |* 18 | INDEX UNIQUE SCAN | PK_TAB6 | 1 | 13 | 1 |
    |* 19 | INDEX RANGE SCAN | PK_TAB7 | 1 | 26 | 1 |
    |* 20 | INDEX UNIQUE SCAN | PK_TAB8 | 1 | 13 | |
    | 21 | TABLE ACCESS BY INDEX ROWID| TAB9 | 3 | 78 | 1 |
    |* 22 | INDEX UNIQUE SCAN | PK_TAB9 | 1 | | |
    |* 23 | INDEX UNIQUE SCAN | PK_TAB10 | 1 | 13 | |
    | 24 | BUFFER SORT | | 1 | 6 | 9 |
    | 25 | TABLE ACCESS BY INDEX ROWID | TAB2 | 1 | 6 | 1 |
    |* 26 | INDEX RANGE SCAN | TAB2_IDX2 | 1 | | |
    |* 27 | TABLE ACCESS BY INDEX ROWID | TAB1 | 12 | 468 | 1 |
    |* 28 | INDEX UNIQUE SCAN | PK_TAB1 | 1 | | |
    Predicate Information (identified by operation id):
    2 - filter(ROWNUM<=3)
    10 - access("TAB5"."PATH_ID"="TAB4"."PATH_ID")
    12 - filter("TAB3"."AUTH_GROUP_ID"<>(-1) AND ("TAB3"."AUTH_GROUP_ID"=0 OR "TAB3"."AUTH_GROUP_ID"=1))
    13 - access("TAB3"."PATH_ID"="TAB4"."PATH_ID")
    18 - access("TAB5"."DOMAIN_ID"="TAB6"."DOMAIN_ID")
    19 - access("TAB6"."DOMAIN_ID"="TAB7"."DOMAIN_ID")
    20 - access("TAB7"."RULE_ID"="TAB8"."RULE_ID")
    22 - access("TAB9"."POLICY_ID"="TAB5"."POLICY_ID")
    23 - access("TAB9"."ASSOCIATED_FORM_ID"="TAB10"."FORM_ID")
    26 - access("TAB2"."CERT_SERIAL_NUM"=1022)
    27 - filter("VIEW2"."POLICY_ID"="TAB1"."POLICY_ID")
    28 - access("TAB1"."TRANSACTION_ID"="TAB2"."TRANSACTION_ID")
    Note: cpu costing is off
    52 rows selected.
    Elapsed: 00:00:03.37
    Execution Plan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 COLLECTION ITERATOR (PICKLER FETCH) OF 'DISPLAY'
    Statistics
    38 recursive calls
    0 db block gets
    287 consistent gets
    0 physical reads
    0 redo size
    5006 bytes sent via SQL*Net to client
    405 bytes received via SQL*Net from client
    5 SQL*Net roundtrips to/from client
    29 sorts (memory)
    0 sorts (disk)
    52 rows processed

  • Performance with order by clause

    Dear all,
    please find the below query .if i executed without order by it is going to execute with in 2 sec.if i add order by clause
    it is taking more than 2 min.as per the business we need order by clause .plaese suggest me.it's very urgent.
    SELECT "FACILITY_ID","VESSEL_NAME","CLASS_NUM","SURVEY_REPORT_NO","IMO_NUMBER","VESSEL_TYPE","VESSEL_TYPE_ID","PRIMARY_BUILDER","BUILDER_ID","REGISTER_OWNER","ABS_SURVEY_STATUS_ID","ABS_SURVEY_STATUS_DATE","NOT_ASSIGNED_SINCE","NO_OF_FINDINGS","CASE","SPM_ITM_CAT_NAME","LEAST_CONFIDENCE" FROM (SELECT
    V. FACILITY_ID,
    v.vessel_name,
    v.class_num,
    ASR.SURVEY_REPORT_NO,
    V.IMO_NUMBER,
    V.VESSEL_TYPE,
    v.vessel_type_id,
    V.PRIMARY_BUILDER,
    V.BUILDER_ID,
    V.REGISTER_OWNER,
    ASR.ABS_SURVEY_STATUS_ID,
    ASR.abs_survey_status_date,
    ROUND(SYSDATE - ASR.abs_survey_status_date) AS NOT_ASSIGNED_SINCE,
    (SELECT COUNT(1) FROM ABS_FINDINGS WHERE survey_report_no = asr.survey_report_no AND FIN_TAG_STAT_ID IN( 'TG')) AS no_of_findings,
    CASE WHEN ( SELECT rnum FROM (SELECT survey_report_no,COUNT(rnum) rnum FROM (SELECT a.survey_report_no,COUNT(*) rnum FROM ABS_FINDINGS A,ABS_SURVEY_REPORTS b
         WHERE a.survey_report_no=b.survey_report_no
         GROUP BY a.survey_report_no,spm_item_category) GROUP BY survey_report_no ) WHERE survey_report_no=asr.survey_report_no )=1 THEN
    ( SELECT spm_item_cat_id FROM ABS_FINDINGS WHERE survey_report_no = asr.survey_report_no AND ROWNUM<2)
    ELSE
    5
    END CASE,
    (SELECT SPM_ITM_CAT_NAME FROM SPM_ITEM_CATEGORIES WHERE SPM_ITEM_CAT_ID =
    (CASE WHEN ( SELECT rnum FROM (SELECT survey_report_no,COUNT(rnum) rnum FROM (SELECT a.survey_report_no,COUNT(*) rnum FROM ABS_FINDINGS A,ABS_SURVEY_REPORTS b
         WHERE a.survey_report_no=b.survey_report_no
         GROUP BY a.survey_report_no,spm_item_category) GROUP BY survey_report_no ) WHERE survey_report_no=asr.survey_report_no )=1 THEN
    ( SELECT spm_item_cat_id FROM ABS_FINDINGS WHERE survey_report_no = asr.survey_report_no AND ROWNUM<2)
    ELSE
    5
    END )) AS SPM_ITM_CAT_NAME,
    (SELECT MIN(tag_weight) FROM TAGGED_FINDINGS
              WHERE finding_id IN (SELECT finding_id FROM ABS_FINDINGS WHERE survey_report_no IN (ASR.SURVEY_REPORT_NO))) AS least_confidence
    FROM
    ABS_SURVEY_REPORTS ASR,
    ABS_VESSELS V
    WHERE
    ASR.FACILITY_ID = V.FACILITY_ID
    AND abs_survey_Status_id = 1 ) WHERE no_of_findings>0
    ORDER BY ABS_SURVEY_STATUS_DATE
    Thanks
    venkat

    Please start reading these informative links first:
    HOW TO: Post a SQL statement tuning request - template posting
    When your query takes too long ...
    and then rephrase your question by posting
    - database version
    - execution plans
    - etc. (see the links above)
    Put the tag before and after your examples, so it'll stay formatted.
    See: http://forums.oracle.com/forums/help.jspa                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Server 2012 R2 slow performance over all

    This is a DELL PowerEdge R820 / 256GB RAM / 4TB onboard storage configured as Remote Desktop Services Host /TS... running QuickBooks, MS Office 2010 STD, Symantec EndPoint Protection (basic antivirus installation ONLY)... 1 month old server... SUPER fast,
    super powerfull.... Part of an AD in SBS 2008 Premium... single NIC card 4 ports / 3 ports disabled. single IP... no VLANS... server is able to resolve ANY pc, DNS record with no problems... able to resolve DC by name, able to receive GP, able to update, able
    to do everything that I can think of.... EXCEPT... anything I open, word, excel, QuickBooks, IE.... takes forever to open... after the application is open is fast but to open anything takes 3-4 minutes.... open ticket with Symantec all looks good, created
    lots of exceptions for antivirus/real time scanning, open ticket with QuickBooks: files look good application was removed and reinstalled to be sure all was done correctly... check the binding order for the disabled NIC; the active one is TOP option, no errors
    at all in event viewers for system, application, setup, no errors at all in DELL management tool, no hard drive errors, no controllers errors.... this server is replacing an old dell poweredge 2008 STD with 24GB RAM... the old DELL opens the same applications
    way faster than the new one... same Quicken version; old server opens Quicken in seconds, new one 3-4 minutes..... Real time monitoring NEVER goes above 1% for CPU and 3% for memory utilization.... one more thing... removed antivirus 100% restart... same performance
    without antivirus.....
    Any ideas will be great as of how to troubleshoot the slow performance....
    Thank you!

    Hi,
    As Sam suggested, please check if there any issue occurred in hard drive.
    On current situation, please also refer to following steps and troubleshoot, then check if we can find more
    clues.
    Please check if you have installed all necessary updates for the Windows Server 2012 R2.
    Please
    perform a clean boot to check if there has software conflicts.
    Please use Resource Monitor to troubleshoot and check if we can find some more details.
    Using Resource Monitor to Troubleshoot Windows Performance Issues Part 1
               Using
    Resource Monitor to Troubleshoot Windows Performance Issues Part 2
    If any update, please feel free to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • Slow performance-CS4, why?

    Hi,
    I have a Q9450 proccessor, Vista 64 bit with 4GB ram. ever since I installed CS4, things are going a bit slow in PPRO, and I don't understand why?
    For example, scrubbing or playback in the timeline have become painfully slow, and sometimes, I see leftovers of the marker, as if I don't have enough memory (it's hard to explain in writing... I hope
    you got it). Overall, all the symptoms shows I don't have enough memory, because of the slow performance, but it doesn't make sense, cause I have 4 GB, and in CS3 it all worked great.
    Any suggetsions?

    worked just great...
    I don't get it.
    I googled a bit and found this thread:
    http://dvxuser.com/V6/showthread.php?t=149929&page=4
    read what Dave Helmly at Adobe had to say (below):
    YES we use all Cores for playback , effects, and rendering for both Mac and Windows.
    I highly recommend switching to Vista 64 if you are a Windows user (Mac guys are OK with 10.5.4 or higher) Vista 64 will allow Production Premium CS4 to run using more than 4GB of Ram (XP/Vista32 Limitation). As with most NLEs, there are several programs running at the same time to give you the NLE experience. CS4 now allows each process to take up to 4Gb of RAM. If you have 16GB of RAM, then 4 processes can take up to 4GB each. This is a HUGE advantage over CS3. What are some examples of processes? DynamicLink, AfterServer, Photoshop Server, Adobe Media Encoder, Titler, Playback, Capture, Importer, and many more. I tell most people to count on buying 8GB minium.
    So maybe I have to add more ram, in order CS4 to run properly...
    Roy

  • Slow performance LR 1.3.1 (Library Module)

    LR 1.2 is running OK on my iMac. A while ago I tried LR 1.3. The upgrade really slowed down performance. Mostly a lag in the sliders and navigation tools in both Library and Develop modules that made it unworkable to me. I changed back to LR 1.2.
    Since I want to import Canon G9 RAW files into LR, I upgraded to LR 1.3.1 recently. Performance of sliders and the navigation tool in the Develop module seems the same as in LR 1.2 (or maybe even a little better). Which means it is OK (workable). It still shows the blur when navigating a 100% zoomed image though. But the navigation tool in the Library module still has the same slow performance as it had in LR 1.3. Unworkable!!! I tried everything: optimizing, new catalog, rendering previews, etc.
    I need the Library module to work smoothly (as in LR 1.2) in order to compare images at 100% zoom. I am afraid I have to go back to LR 1.2 again and find another solution for my Canon G9 RAW files. Most inconvenient. I am very disappointed. Especially, since Adobe showed they CAN get it right with the Develop module in version LR 1.3.1...
    Oh yeah, my system specs:
    iMac 2.16 GHz Intel Core 2 Duo
    3GB 667 Mhz DDR2 SDRAM (2GB + 1GB)
    232,89 GB Harddrive, 113 GB available
    ATI Radeon X1600 128MB
    Mac OS 10.4.11
    Please Adobe, make the Library module run as smoothly as the Develop module in version 1.3.2...

    The preview folder is 2,11 GB big. The .lrcat is 47 MB big.
    I opened a new test catalog. I imported 326 images. After the import I rendered 1:1 previews. It took a long time. Real memory used was between 700-1000MB. Virtual memory used was between 1000-1400MB. When it was done rendering it still keep on using 700MB real memory and 1000MB virtual memory. I had to close LR and restart. Real memory after restart was 75MB real memory and 375 virtual memory.
    But it didn't matter. The lag in the navigation tool of the Library module was still there.
    I noticed that when clicking in the navigation window there was less delay as when I slide the white square in the window (in Library module). In the develop module this seems the other way around. Sliding showed less delay than clicking.
    What's going on here?
    I also have a MacBook. Performance seems much faster than on my iMac overall. After creating a new catalog and rendering 1:1 previews, the lag in the navigation window seems less than before. But it was still there...

  • Slow performance for large queries

    Hi -
    I'm experiencing slow performance when I use a filter with a very large OR clause.
    I have a list of users, whose uid's are known, and I want to retrieve attributes for all users. If I do this one at a time, I pay the network overhead, and this becomes a bottleneck. However, if I try to get information about all users at once, the query runs ridiculously slow - ~ 10minutes for 5000 users.
    The syntax of my filter is: (|(uid=user1)(uid=user2)(uid=user3)(uid=user4).....(uid=user5000))
    I'm trying this technique because it's similar to good design for oracle - minimizing round trips to the database.
    I'm running LDAP 4.1.1 on a Tru64 OS - v5.1.

    This is a performance/tuning forum for iPlanet Application Server. You'd have better luck with this question on the Directory forum.
    The directory folks don't have a separate forum dedicated to tuning, but they answer performance questions in the main forum all of the time.
    David

  • Slow performance of PreparedStatement

    I am having difficulty with extremely slow performance or a relatively simply Microsoft SQL Server 2000 call from my Java applet. Most of the application runs fine, but there are certain parts that are repeatedly giving me a long delay before completing their execution. The code is as follows:
    // Create the try block for the execution of the SQL code
            try{
                // Create the command to be executed
                String command = new String( "select Description, Enabled " );
                command += "from tLineInfo where( Line = ? )";
                // Create the SQL text to be executed
                PreparedStatement get = _connection.prepareStatement( command );
                get.setInt( 1, lineNo );
                // Execute the SQL command
                ResultSet lineInfo = get.executeQuery();
                // Display the information accordingly
                if( lineInfo.next() ){
                    // Populate the user data fields
                    description.setText( lineInfo.getString( "Description" ) );
                          <! more display code here >
    }   // End of if statment
                else{
                    // Clear the user data fields
                    description.setText( " " );
                           <! more display code here >
                }   // End of else statements
                // Close the result set in preparation for the next query
                lineInfo.close();
            }   // End of try block
            catch( Exception e ){
                // Display a dialog box informing the user of the problem
                Object[] options = { "     OK     " };
                JOptionPane.showOptionDialog( null, e.getMessage(),
                        "Error",
                        JOptionPane.OK_OPTION, JOptionPane.ERROR_MESSAGE,
                        null, options, options[ 0 ] ); 
            }   // End of Exception catch
            // Get the related area information
            populateAreaCombo( lineNo );       
    private void populateAreaCombo( int lineNo ){
            // Format the areaComboBox
             try{
                // Create a command to get the devices from the database
                String command = new String( "select Area, [Name], [Description] " );
                command += "from tAreas where( Line = ? )";
                // Create the SQL statement to grab the information, and
                // populate the search parameter
                PreparedStatement getAreas =
                        _connection.prepareStatement( command );
                getAreas.setInt( 1, lineNo );
                // Execute the command
                ResultSet areas = getAreas.executeQuery();
                // Loop through the result set, and add collect the areas
                Vector< String > controlAreas = new Vector();
                while( areas.next() ){
                    // Add the area to the comboBox
                    controlAreas.add( Integer.toString( areas.getInt( "Area" ) ) +
                            " - " + areas.getString( "Name" ) + ": " +
                            areas.getString( "Description" ) );
                }   // End of while loop
                      <! more display code here >
                    The application always seem to pause at the second PrepraredStatement call:
    PreparedStatement getAreas =
                        _connection.prepareStatement( command );This seems to be a very simple operation, and it is not even the execution of the query where the long delay is realized. Rather, it is in the actual creation of the object prior to the execution.
    The delay is very repeatable at this exact statement each time.
    Additionally, of interest, is that the delay is only realized on computers remotely connected to the database. If I run this code on the localhost, then there is no delay. As soon as I distribute it, then the delay is incurred. That being said, there is not a network related issue that I can identify here. I have even isolated the server to be on the network with just one other PC, and the delay still persisted.
    Does anyone have any ideas?
    Thanks

    I can determine where the delay occurs by adding
    dialog boxes at a bunch of different steps, then
    monitoring them for when they appear; a little
    archaic, of course, but an easy way to find this
    out.You should
    1. Get the start time
    2. Get the current time at each step.
    3. Print the results at the end.
    4. Repeat a number of times to average.
    >
    When you say that I should not mix database code with
    display code... What exactly do you mean? To be
    more precise in my description, I was simply setting
    a bunch of different text fields and/or check boxes,
    etc., based on the result set returned. It was not
    as if I was creating a portion of the GUI there or
    something. I am assuming that is an allowable
    practice...
    You should have a class that does nothing but the database work. That class should be used by other classes (like classes that do GUI.)
    I have made little effort to close my resources, and
    sometimes they are not closed at all. When you say
    "resources", what exactly do you mean by that? Are
    you referring to the result sets, for example? I do
    not know of other resources that need to be closed,
    except for the connection to the DB itself. This, I
    have as persistent throughout the duration of the
    user's session.
    You must close result sets, statements and connections. They must be closed in that order.
    I am not running this code on the Internet, but it
    has been designed to be run on a small corporate
    network ( < 10 users). This is why I opted for the
    applet to run the entire application through instead
    of doing more HTML work.That is ok.

  • Sorting character column ( used in order by clause dynamically)

    Hi,
    I need help on sorting character-based numbers. Like say, I want to sort customers based on street numbers(which is a character string being used in the
    order by clause) they live in.
    The criteria are :
    i. Numbers must take precedence.
    This being a character string, 1000001 comes before 2. This shouldn't happen. And you cannot use to_number
    since using it with a string having characters in it would raise an error.
    ii. If only a single alphabet occurs as the last character, then treat the whole string as a number except the last character and then sort it
    as if sorting a number. Something like : if you have 1000A, 200D, 200B, 1000X, the result would be 200B,200D,1000A,1000X.
    iii. if a character occurs elsewhere in the string, then perform the search normally as if performing a character search.
    The output of the following data :
    100
    A101
    B100A
    110C
    C120B
    120
    100020
    120C
    C1100
    100D
    would be like :
    100
    100D
    110C
    120
    120C
    100020
    A101
    B100A
    C120B
    C1100
    Please note that the sort is being done dynamically, so I could have access to the values of the street numbers only during run time.
    Any help is really appreciated.
    Thanks in advance.
    Regards,
    Anil.

    Create a function to test whether the column is numeric :
    create FUNCTION is_numeric(v_number VARCHAR2)
    RETURN INTEGER
    IS
    l_number NUMBER;
    BEGIN
    IF INSTR(UPPER(v_number),'E') > 0 THEN
    RETURN 0;
    END IF;
    l_number := TO_NUMBER(v_number);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    And try this query
    Assume the table name is TEST with column STREET
    select * from TEST
    order by case is_numeric(STREET) when 1 then LPAD(STREET,20, ' ') else STREET end
    Please make sure that 20 mentioned above is the column size for STREET.
    Hope this helps.
    -Nags

  • Problem in sql query because of order by clause

    Hi All,
    I am facing a one problem in my one sql query.I am using Oracle 10gR2.
    Query is given below:
    SELECT t1.ename
            FROM T1, T2
           WHERE T1.EMPNO = 1234
             AND T1.ACCOUNTNO = T2.ACCOUNTNO
             AND T1.SEQ = T2.SEQ
           ORDER BY T2.SEQThe Plan of the query is :
    | Id  | Operation                     | Name                 | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  1 |  TABLE ACCESS BY INDEX ROWID  | T1                   |     1 |    89 |     1   (0)| 00:00:01 |
    |   2 |   NESTED LOOPS                |                      |     2 |   218 | 11716   (1)| 00:00:41 |
    |*  3 |    TABLE ACCESS BY INDEX ROWID| T2                   |     2 |    40 | 11715   (1)| 00:00:41 |
    |   4 |     INDEX FULL SCAN           | PK_T2_SEQ            | 58752 |       |   122   (5)| 00:00:01 |
    |*  5 |    INDEX RANGE SCAN           | FK_ACCOUNTNO         |     3 |       |     0   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------------------Now i want to reduce the time of this query.
    If i am removing Order by clause from query than performance of the query is totally perfect but with order by clause its taking a time.
    I have already set SORT_AREA_SIZE but still nothing is improving.
    Welcome and thanks for your suggestions.
    Thanks,
    Edited by: BluShadow on 23-Jun-2011 07:55
    added {noformat}{noformat} tags and formatted explain plan to make it readable.  Please see {message:id=9360002} for details on how to post code and data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    Hi,
    There are a couple of things I do not understand.
    1. Why don't you put {noformat}{noformat} around your code, it makes it so much easier to read, especially your explain plan
    2. You claim that the ORDER BY is problematic compared to no order by. Then why do you choose to post only one plan?
    3. It is hard to understand how your tables relate, and which indexes you have and which you don't.
    - PK_T2_SEQ, does this mean that SEQ alone is primary key of T2?
    - If SEQ is primary key of T2, why do you join on accountno, seq and not just seq?
    - If SEQ is primary key of T2 one of the tables is denormalized.
    4. FK_ACCOUNTNO, is this an index on accountno, alone?
    - Or is this AccountNo, Seq?
    5. Is there no index on T1.EMPNO?
    Above could of course just be a case of my not understanding the names of your indexes.
    So, here are my guesses:
    Above plan is for the ORDER BY query. That means the optimizer, has chosen to full scan PK_T2_SEQ, since data is then read according to the ORDER BY.
    (This could be a bad choice)I
    You could try and order by t1.seq, instead. Result should be the same.
    Regards
    Peter                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Sudden extreme slow performance

    I have run Tiger on this machine for about 6 months with no problems. In the last few weeks everything has started slowing down noticably. The hard disk is running ragged, constantly reading/writing, from looking at the cpu monitor it seems like the computer is not actually using it's ram and is just reading and writing. I tried clearing caches and that worked for a few hours but the machine now seems to lock up after a few hours use. I get to the point where i cannot open menus, switch programs, or even force quit or restart. Everything locks up - spinning beachball - and the hard disk is left constantly writing. I have 9 -15Gb free out of 40Gb on the disk - i assume this is enough. Playing music and safari is no problem. But I am using iphoto and photoshop as well as other programs in the background. This was never previously a problem and ran smoothly. I know it's fairly vague but if anyone can help..

    Hi, Ben.
    Thanks. However, it would help to see some of the specific data points from the instructions in those FAQs. Specifically:
    1. You wrote: "(the pageins/outs are about equal) but i'm getting REALLY slow performance across the board. "It still sounds like it is "thrashing."1.1. Did you check the pagesin/pageouts per second as described in my "Problems from insufficient RAM and free hard disk space" FAQ? The per-second values can only be found using top as described therein.
    1.2. Did you check for a runaway process in Activity Monitor per the "Troubleshooting" section in my "Tuning Mac OS X Performance" FAQ?.
    The activity you describe (beach ball, heavy disk writing) has to be coming from somewhere, so checking Activity Monitor as I describe in that FAQ should tell you. Find the process consuming the most %CPU as instructed in the FAQ. Post back the result, i.e. the process name.2. You wrote: "It seems to lock itself up with the hard disk clicking and crunching. Is it possible the hard disk is giving up and so is writing at a very slow speed??? "To check this, see my "Resolving Disk, Permission, and Cache Corruption" FAQ:2.1. Perform at least Steps 1-3 of the Procedure section therein in the order specified.
    2.2. Also, review the section therein on "Bad Sectors" to see if the "clicking and crunching" sounds you are hearing are similar to those that generally indicate bad sectors.3. If the disk checks out OK per point 2 above, and depending on what you find in point 1.2 above, the process may be an errant Startup or Login Item. My "Troubleshooting Startup and Login Items" FAQ can help you pin that down if such an item is causing the problem.
    Good luck!
    Dr. Smoke
    Author: Troubleshooting Mac® OS X
    Note: The information provided in the link(s) above is freely available. However, because I own The X Lab™, a commercial Web site to which some of these links point, the Apple Discussions Terms of Use require I include the following disclosure statement with this post:
    I may receive some form of compensation, financial or otherwise, from my recommendation or link.

  • Order by clause require dynamic value

    Hi
    I want to bind parameters to orderby clause. In where clause with bind parameter works fine. But in orderby clause ive done similar steps to have a dynamic sort which will be passed from the previous page in a session variable. Although it didnt show any error at the backend where i can see data getting binded, but no sorting is taking place.
    Can u help me to solve this.
    regards
    Jayashri

    Jayashri,
    I have tested this and you are right. And there does occur an error at the backend, only you wont see it unless you run with BC4J debug mode turned on. You can do this by providing -Djbo.debugoutput=console to the JVM. When running inside JDeveloper, you can accomplish this by going to Project Properties => PRofiles => Development => "Runner", and fill this in at the "Java Options" field.
    Doing that will show the reason of the problem. When a view object is queried, BC4J actually performs 2 queries. One to obtain the 'estimated row count', and then one to obtain the action rows.
    Now suppose your query looks like this:
    SELECT <somefields> FROM <table>
    WHERE <field> = :1 ORDER BY :2
    Bc4j will construct the following query to obtain the estimated rowcount:
    SELECT count(1) FROM (SELECT <somefields> FROM <table> WHERE <field> = :1)
    As you can see, it does NOT include the ORDER BY of the original query in this statement, probably for performance reasons (why order the set if you are only interested in the count). Unfortunately, it WILL try to bind both :1 AND :2 to this query, but because there is only one bind variable in this query, this throws an java.sql.SQLException which is unfortunately trapped somewhere in BC4J code, and not shown in the regular log file.
    I am pretty confident that this is actually a BC4J bug (or known restriction). You could post this problem at the JDeveloper Forum to determine this (without mentioning JHeadstart, because this would also happen if you wrote your own code for binding these parameters).
    As for a workaround, you could try the following:
    1.) Remove the (bind parameter from) the order by clause on the ViewObject
    2.) Remove that same bind parameter from the "Query Bind Parameters" property.
    You should now have gone back to a scenario where there are only bind parameters on the where clause. You would need to set the OrderBy clause programatically now. To do this, extend the JhsDataAction for this page, and override the method 'applyIterBindParams()'. Before calling super, try something like:
    ViewObject vo = ib.getRowSetIterator().getRowSet().getViewObject();
    vo.setOrderByClause(<your dynamic orderby>);
    Kind regards,
    Peter Ebell
    JHeadstart Team

Maybe you are looking for

  • Returning error messages to shell with TERMOUT OFF

    Hi all, I did a search in this forum and I couldn't find the answer. I am unloading (spooling) a table using SQLPLUS. Since I don't want to display these records on screen I am using set termout off. But I want to see error messages on the screen. I

  • Cd drive for imac

    Hi, I have a iMac 3GHz Intel Core i3 since 2011 and now, after I installed Maverics iOS the CD ROOM drive stopped work. I did all requested updates I don't know why, but the CD ROOM Driver don't pull CD. I know that don't have CD's inside. Please, I

  • EliteBook Folio 9470n Fan 90B

    My laptop is only 5 days old and I am getting an error at start up that my cooling fan is not working and go to this message board for help mentioning Fan 90B. The only responses I see are to clean the vents and try again. Come on, this is a brand ne

  • Can't stabilize digitized video?

    I attempted to analyze an entire 2 hour clip captured by digitizing an 8mm analog tape. Analysis took about a day, and the surprising result was a two-hour-long red squiggle. Is this "normal", that you can't apply stabilization to analog conversions?

  • Does new MacBookPro 13" (Apr2010) run all Final Cut Studio applications?

    Does the new MacBookPro 13" (April 2010) run all Final Cut Studio applications, and reasonably well? I've looked at the FCS specs, CPU, RAM and hard disc minimums are more than satisfied with the MBP 13". Now that the 13" has a discreet Nvidia (albei