Quantcast
Channel: SCN: Message List - SAP Adaptive Server Enterprise (SAP ASE) for Custom Applications
Viewing all articles
Browse latest Browse all 3587

insert select statement is taking ages

$
0
0

Sybase version: Adaptive Server Enterprise/12.5.4/EBF 15432 ESD#8/P/Sun_svr4/OS 5.8/ase1254/2105/64-bit/FBO/Sat Mar 22 14:38:37 2008

 

Hi guyz,

 

I have a question about the performance of a statement that is very slow and I'd like to have you input.

 

I have the SQL statement below that is taking ages to execute and I can't find out how to imporve it


insert SST_TMP_M_TYPE select M_TYPE from MKT_OP_DBF M join TRN_HDR_DBF T on M.M_ORIGIN_NB=T.M_NB where T.M_LTI_NB=@Nson_lti

 

@Nson_lti is the same datatype as T.M_LTI_NB


M.M_ORIGIN_NB=T.M_NB have the same datatype

 

TRN_HDR_DBF has 1424951 rows and indexes on M_LTI_NB and M_NB


table MKT_OP_DBF has 870305 rows


table MKT_OP_DBF has an index on M_ORIGIN_NB column
Statistics for index:                   "MKT_OP_ND7" (nonclustered)
Index column list:                      "M_ORIGIN_NB"
     Leaf count:                        3087
     Empty leaf page count:             0
     Data page CR count:                410256.0000000000000000
     Index page CR count:               566.0000000000000000
     Data row CR count:                 467979.0000000000000000
     First extent leaf pages:           0
     Leaf row size:                     12.1161512343373872
     Index height:                      2

 

The representaion of M_ORIGIN_NB is
Statistics for column:                  "M_ORIGIN_NB"
Last update of column statistics:       Mar  9 2015 10:48:57:420AM

     Range cell density:                0.0000034460903826
     Total density:                     0.0053334921767125
     Range selectivity:                 default used (0.33)
     In between selectivity:            default used (0.25)

Histogram for column:                   "M_ORIGIN_NB"
Column datatype:                        numeric(10,0)
Requested step count:                   20
Actual step count:                      20

     Step     Weight                    Value

        1     0.00000000        <       0
        2     0.07300889        =       0
        3     0.05263098       <=       5025190
        4     0.05263098       <=       9202496
        5     0.05263098       <=       12664456
        6     0.05263098       <=       13129478
        7     0.05263098       <=       13698564
        8     0.05263098       <=       14735554
        9     0.05263098       <=       15168461
       10     0.05263098       <=       15562067
       11     0.05263098       <=       16452862
       12     0.05263098       <=       16909265
       13     0.05263212       <=       17251573
       14     0.05263098       <=       18009609
       15     0.05263098       <=       18207523
       16     0.05263098       <=       18404113
       17     0.05263098       <=       18588398
       18     0.05263098       <=       18793585
       19     0.05263098       <=       18998992
       20     0.03226340       <=       19574408

 

If I look at the showplan, I can see indexes on TRN_HDR_DBF are used but now the one on MKT_OP_DBF
QUERY PLAN FOR STATEMENT 16 (at line 35).


    STEP 1
        The type of query is INSERT.
        The update mode is direct.

        FROM TABLE
            MKT_OP_DBF
            M
        Nested iteration.
        Table Scan.
        Forward scan.
        Positioning at start of table.
        Using I/O Size 32 Kbytes for data pages.
        With LRU Buffer Replacement Strategy for data pages.

        FROM TABLE
            TRN_HDR_DBF
            T
        Nested iteration.
        Index : TRN_HDR_NDX_NB
        Forward scan.
        Positioning by key.
        Keys are:
            M_NB  ASC
        Using I/O Size 4 Kbytes for index leaf pages.
        With LRU Buffer Replacement Strategy for index leaf pages.
        Using I/O Size 4 Kbytes for data pages.
        With LRU Buffer Replacement Strategy for data pages.
        TO TABLE
            SST_TMP_M_TYPE
        Using I/O Size 4 Kbytes for data pages.

 

I was expecting the query to use the index also on MKT_OP_DBF

Thanks for your advices

 

Simon


Viewing all articles
Browse latest Browse all 3587

Trending Articles