insert query takes too long ....

  • I have a insert query in stored procedure it takes min 59 or 110 specs to insert into table.
    query is
    insert into tab1
    select distinct col1,col2,.....
    if I change select  distinct to top keyword it executes in secs....
    How to  improve performance of this query....

  • Well how fast does the just the select run without the insert?

    And how many rows does the distinct return vs. how many rows you were returning with the TOP X

  • savibp3 - Thursday, March 23, 2017 6:41 AM

    I have a insert query in stored procedure it takes min 59 or 110 specs to insert into table.
    query is
    insert into tab1
    select distinct col1,col2,.....
    if I change select  distinct to top keyword it executes in secs....
    How to  improve performance of this query....

    In this case, the SELECT part of the query takes too long. Please post the actual execution plan of the SELECT part as a .sql file attachment. Thanks.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • ZZartin - Thursday, March 23, 2017 8:01 AM

    Well how fast does the just the select run without the insert?

    And how many rows does the distinct return vs. how many rows you were returning with the TOP X

    well if itry to insert 4 lakh row with top key work it executes fast but with distinct to insert even 1 lakh rows it takes 59 secs

  • You need to do what Chris is suggesting, get the execution plan. We can speculate all day why one query runs faster than another (although DISTINCT is an aggregation function and notorious for causing performance issues when it's used inappropriately, so there's that) but without evidence, all we're doing is guessing.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey - Thursday, March 23, 2017 9:07 AM

    You need to do what Chris is suggesting, get the execution plan. We can speculate all day why one query runs faster than another (although DISTINCT is an aggregation function and notorious for causing performance issues when it's used inappropriately, so there's that) but without evidence, all we're doing is guessing.

    Summary Count Max Total
    Reads 3 9002726 9032989
    Writes 1 33973 33973
    Elapsed Time 1 41593 41593
    CPU Time 1 29200 29200
    EXE Time 1 29200 29200

    Count Max Total Summary
    1 23272 23272 Worktable1
    1 9002726 9002726 resonvloader_event_queue
    1 6991 6991 open_orders
    1 33973 33973 
    # Proc Total IOs Table R Scan IOs/Time
    1 <batch>:0003 9066962 resonvloader_event_queue R 0 9002726
    2 <batch>:0003 9066962 Worktable1 R 1 23272
    3 <batch>:0003 9066962 open_orders R 1 6991
    4 <batch>:0003 9066962  W 1 33973
    5 <batch>:0003 0  Exec Time 0 29200
    6 <batch>:0003 0  CPU Time 0 29200
    7 <batch>:0003 0  Elapsed Time 0 41593

  • savibp3 - Thursday, March 23, 2017 9:21 AM

    Grant Fritchey - Thursday, March 23, 2017 9:07 AM

    You need to do what Chris is suggesting, get the execution plan. We can speculate all day why one query runs faster than another (although DISTINCT is an aggregation function and notorious for causing performance issues when it's used inappropriately, so there's that) but without evidence, all we're doing is guessing.

    Summary Count Max Total
    Reads 3 9002726 9032989
    Writes 1 33973 33973
    Elapsed Time 1 41593 41593
    CPU Time 1 29200 29200
    EXE Time 1 29200 29200

    Count Max Total Summary
    1 23272 23272 Worktable1
    1 9002726 9002726 resonvloader_event_queue
    1 6991 6991 open_orders
    1 33973 33973 
    # Proc Total IOs Table R Scan IOs/Time
    1 <batch>:0003 9066962 resonvloader_event_queue R 0 9002726
    2 <batch>:0003 9066962 Worktable1 R 1 23272
    3 <batch>:0003 9066962 open_orders R 1 6991
    4 <batch>:0003 9066962  W 1 33973
    5 <batch>:0003 0  Exec Time 0 29200
    6 <batch>:0003 0  CPU Time 0 29200
    7 <batch>:0003 0  Elapsed Time 0 41593

    That is not the execution plan posted as an attachment to this thread. That is what you need to do for us to effectively help you.

    Best,
    Kevin G. Boles
    SQL Server Consultant
    SQL MVP 2007-2012
    TheSQLGuru on googles mail service

  • TheSQLGuru - Thursday, March 23, 2017 9:25 AM

    savibp3 - Thursday, March 23, 2017 9:21 AM

    Grant Fritchey - Thursday, March 23, 2017 9:07 AM

    You need to do what Chris is suggesting, get the execution plan. We can speculate all day why one query runs faster than another (although DISTINCT is an aggregation function and notorious for causing performance issues when it's used inappropriately, so there's that) but without evidence, all we're doing is guessing.

    Summary Count Max Total
    Reads 3 9002726 9032989
    Writes 1 33973 33973
    Elapsed Time 1 41593 41593
    CPU Time 1 29200 29200
    EXE Time 1 29200 29200

    Count Max Total Summary
    1 23272 23272 Worktable1
    1 9002726 9002726 resonvloader_event_queue
    1 6991 6991 open_orders
    1 33973 33973 
    # Proc Total IOs Table R Scan IOs/Time
    1 <batch>:0003 9066962 resonvloader_event_queue R 0 9002726
    2 <batch>:0003 9066962 Worktable1 R 1 23272
    3 <batch>:0003 9066962 open_orders R 1 6991
    4 <batch>:0003 9066962  W 1 33973
    5 <batch>:0003 0  Exec Time 0 29200
    6 <batch>:0003 0  CPU Time 0 29200
    7 <batch>:0003 0  Elapsed Time 0 41593

    That is not the execution plan posted as an attachment to this thread. That is what you need to do for us to effectively help you.

    Parse and Compile Time 0.361310null301ZZZ0SERVER_NAME1
    Adaptive Server cpu time: 0 ms.010null3null1SERVER_NAME2
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010null1null1SERVER_NAME3
    624810PROCNAME001ZZZ4SERVER_NAME4
    QUERY PLAN FOR STATEMENT 1 (at line 0).628910PROCNAME001ZZZ1SERVER_NAME5
    624810PROCNAME001ZZZ4SERVER_NAME6
    624810PROCNAME001ZZZ4SERVER_NAME7
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME8
    The type of query is DECLARE.620310PROCNAME001ZZZ2SERVER_NAME9
    624810PROCNAME001ZZZ4SERVER_NAME10
    624810PROCNAME001ZZZ4SERVER_NAME11
    QUERY PLAN FOR STATEMENT 2 (at line 10).628910PROCNAME001ZZZ1SERVER_NAME12
    624810PROCNAME001ZZZ4SERVER_NAME13
    624810PROCNAME001ZZZ4SERVER_NAME14
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME15
    The type of query is SELECT.1026210PROCNAME001ZZZ1SERVER_NAME16
    624810PROCNAME001ZZZ4SERVER_NAME17
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME18
    624810PROCNAME001ZZZ4SERVER_NAME19
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME20
    |624810PROCNAME001ZZZ170SERVER_NAME21
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME22
    624810PROCNAME001ZZZ4SERVER_NAME23
    624810PROCNAME001ZZZ4SERVER_NAME24
    624810PROCNAME001ZZZ4SERVER_NAME25
    QUERY PLAN FOR STATEMENT 3 (at line 11).628910PROCNAME001ZZZ1SERVER_NAME26
    624810PROCNAME001ZZZ4SERVER_NAME27
    624810PROCNAME001ZZZ4SERVER_NAME28
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME29
    The type of query is SELECT.1026210PROCNAME001ZZZ1SERVER_NAME30
    624810PROCNAME001ZZZ4SERVER_NAME31
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME32
    624810PROCNAME001ZZZ4SERVER_NAME33
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME34
    |624810PROCNAME001ZZZ170SERVER_NAME35
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME36
    624810PROCNAME001ZZZ4SERVER_NAME37
    624810PROCNAME001ZZZ4SERVER_NAME38
    624810PROCNAME001ZZZ4SERVER_NAME39
    QUERY PLAN FOR STATEMENT 4 (at line 23).628910PROCNAME001ZZZ1SERVER_NAME40
    624810PROCNAME001ZZZ4SERVER_NAME41
    624810PROCNAME001ZZZ4SERVER_NAME42
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME43
    The type of query is BEGIN TRANSACTION.620310PROCNAME001ZZZ2SERVER_NAME44
    624810PROCNAME001ZZZ4SERVER_NAME45
    624810PROCNAME001ZZZ4SERVER_NAME46
    QUERY PLAN FOR STATEMENT 5 (at line 26).628910PROCNAME001ZZZ1SERVER_NAME47
    624810PROCNAME001ZZZ4SERVER_NAME48
    624810PROCNAME001ZZZ4SERVER_NAME49
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME50
    The type of query is COND.1026210PROCNAME001ZZZ1SERVER_NAME51
    624810PROCNAME001ZZZ4SERVER_NAME52
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME53
    624810PROCNAME001ZZZ4SERVER_NAME54
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME55
    |624810PROCNAME001ZZZ170SERVER_NAME56
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME57
    624810PROCNAME001ZZZ4SERVER_NAME58
    624810PROCNAME001ZZZ4SERVER_NAME59
    624810PROCNAME001ZZZ4SERVER_NAME60
    QUERY PLAN FOR STATEMENT 6 (at line 28).628910PROCNAME001ZZZ1SERVER_NAME61
    624810PROCNAME001ZZZ4SERVER_NAME62
    624810PROCNAME001ZZZ4SERVER_NAME63
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME64
    The type of query is INSERT.1026210PROCNAME001ZZZ1SERVER_NAME65
    624810PROCNAME001ZZZ4SERVER_NAME66
    4 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME67
    624810PROCNAME001ZZZ4SERVER_NAME68
    |ROOT:EMIT Operator (VA = 4)624810PROCNAME001ZZZ169SERVER_NAME69
    |624810PROCNAME001ZZZ170SERVER_NAME70
    |   |INSERT Operator (VA = 3)624810PROCNAME001ZZZ116SERVER_NAME71
    |   |  The update mode is direct.620410PROCNAME001ZZZ5SERVER_NAME72
    |   |624810PROCNAME001ZZZ123SERVER_NAME73
    |   |   |HASH DISTINCT Operator (VA = 2)624810PROCNAME001ZZZ113SERVER_NAME74
    |   |   | Using Worktable1 for internal storage.1026310PROCNAME001ZZZ1SERVER_NAME75
    |   |   |  Key Count: 6624810PROCNAME001ZZZ118SERVER_NAME76
    |   |   |624810PROCNAME001ZZZ123SERVER_NAME77
    |   |   |   |RESTRICT Operator (VA = 1)(0)(2)(0)(0)(3)624810PROCNAME001ZZZ128SERVER_NAME78
    |   |   |   |624810PROCNAME001ZZZ123SERVER_NAME79
    |   |   |   |   |SCAN Operator (VA = 0)624810PROCNAME001ZZZ132SERVER_NAME80
    |   |   |   |   |  FROM TABLE621510PROCNAME001ZZZ2SERVER_NAME81
    |   |   |   |   |  open_orders621710PROCNAME001ZZZ5SERVER_NAME82
    |   |   |   |   |  oo621710PROCNAME001ZZZ6SERVER_NAME83
    |   |   |   |   |  Index : pk_open_orders622510PROCNAME001ZZZ1SERVER_NAME84
    |   |   |   |   |  Forward Scan.627610PROCNAME001ZZZ2SERVER_NAME85
    |   |   |   |   |  Positioning at index start.628210PROCNAME001ZZZ2SERVER_NAME86
    |   |   |   |   |  Index contains all needed columns. Base table will not be read.628610PROCNAME001ZZZ1SERVER_NAME87
    |   |   |   |   |  Using I/O Size 16 Kbytes for index leaf pages.627210PROCNAME001ZZZ2SERVER_NAME88
    |   |   |   |   |  With LRU Buffer Replacement Strategy for index leaf pages.627310PROCNAME001ZZZ5SERVER_NAME89
    |   |624810PROCNAME001ZZZ106SERVER_NAME90
    |   |  TO TABLE621410PROCNAME001ZZZ2SERVER_NAME91
    |   |  resonvloader_event_queue621710PROCNAME001ZZZ4SERVER_NAME92
    |   |  Using I/O Size 2 Kbytes for data pages.1024010PROCNAME001ZZZ4SERVER_NAME93
    624810PROCNAME001ZZZ4SERVER_NAME94
    624810PROCNAME001ZZZ4SERVER_NAME95
    624810PROCNAME001ZZZ4SERVER_NAME96
    QUERY PLAN FOR STATEMENT 7 (at line 41).628910PROCNAME001ZZZ1SERVER_NAME97
    624810PROCNAME001ZZZ4SERVER_NAME98
    624810PROCNAME001ZZZ4SERVER_NAME99
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME100
    The type of query is COND.1026210PROCNAME001ZZZ1SERVER_NAME101
    624810PROCNAME001ZZZ4SERVER_NAME102
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME103
    624810PROCNAME001ZZZ4SERVER_NAME104
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME105
    |624810PROCNAME001ZZZ170SERVER_NAME106
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME107
    624810PROCNAME001ZZZ4SERVER_NAME108
    624810PROCNAME001ZZZ4SERVER_NAME109
    624810PROCNAME001ZZZ4SERVER_NAME110
    QUERY PLAN FOR STATEMENT 8 (at line 43).628910PROCNAME001ZZZ1SERVER_NAME111
    624810PROCNAME001ZZZ4SERVER_NAME112
    624810PROCNAME001ZZZ4SERVER_NAME113
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME114
    The type of query is INSERT.1026210PROCNAME001ZZZ1SERVER_NAME115
    624810PROCNAME001ZZZ4SERVER_NAME116
    4 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME117
    624810PROCNAME001ZZZ4SERVER_NAME118
    |ROOT:EMIT Operator (VA = 4)624810PROCNAME001ZZZ169SERVER_NAME119
    |624810PROCNAME001ZZZ170SERVER_NAME120
    |   |INSERT Operator (VA = 3)624810PROCNAME001ZZZ116SERVER_NAME121
    |   |  The update mode is direct.620410PROCNAME001ZZZ5SERVER_NAME122
    |   |624810PROCNAME001ZZZ123SERVER_NAME123
    |   |   |HASH DISTINCT Operator (VA = 2)624810PROCNAME001ZZZ113SERVER_NAME124
    |   |   | Using Worktable1 for internal storage.1026310PROCNAME001ZZZ1SERVER_NAME125
    |   |   |  Key Count: 6624810PROCNAME001ZZZ118SERVER_NAME126
    |   |   |624810PROCNAME001ZZZ123SERVER_NAME127
    |   |   |   |RESTRICT Operator (VA = 1)(0)(2)(0)(0)(5)624810PROCNAME001ZZZ128SERVER_NAME128
    |   |   |   |624810PROCNAME001ZZZ123SERVER_NAME129
    |   |   |   |   |SCAN Operator (VA = 0)624810PROCNAME001ZZZ132SERVER_NAME130
    |   |   |   |   |  FROM TABLE621510PROCNAME001ZZZ2SERVER_NAME131
    |   |   |   |   |  netting..order_allocation621710PROCNAME001ZZZ5SERVER_NAME132
    |   |   |   |   |  oo621710PROCNAME001ZZZ6SERVER_NAME133
    |   |   |   |   |  Using Clustered Index.622410PROCNAME001ZZZ3SERVER_NAME134
    |   |   |   |   |  Index : XC_order_allocation622510PROCNAME001ZZZ1SERVER_NAME135
    |   |   |   |   |  Forward Scan.627610PROCNAME001ZZZ2SERVER_NAME136
    |   |   |   |   |  Positioning at index start.628210PROCNAME001ZZZ2SERVER_NAME137
    |   |   |   |   |  Index contains all needed columns. Base table will not be read.628610PROCNAME001ZZZ1SERVER_NAME138
    |   |   |   |   |  Using I/O Size 16 Kbytes for index leaf pages.627210PROCNAME001ZZZ2SERVER_NAME139
    |   |   |   |   |  With LRU Buffer Replacement Strategy for index leaf pages.627310PROCNAME001ZZZ5SERVER_NAME140
    |   |624810PROCNAME001ZZZ106SERVER_NAME141
    |   |  TO TABLE621410PROCNAME001ZZZ2SERVER_NAME142
    |   |  resonvloader_event_queue621710PROCNAME001ZZZ4SERVER_NAME143
    |   |  Using I/O Size 2 Kbytes for data pages.1024010PROCNAME001ZZZ4SERVER_NAME144
    624810PROCNAME001ZZZ4SERVER_NAME145
    624810PROCNAME001ZZZ4SERVER_NAME146
    624810PROCNAME001ZZZ4SERVER_NAME147
    QUERY PLAN FOR STATEMENT 9 (at line 55).628910PROCNAME001ZZZ1SERVER_NAME148
    624810PROCNAME001ZZZ4SERVER_NAME149
    624810PROCNAME001ZZZ4SERVER_NAME150
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME151
    The type of query is COND.1026210PROCNAME001ZZZ1SERVER_NAME152
    624810PROCNAME001ZZZ4SERVER_NAME153
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME154
    624810PROCNAME001ZZZ4SERVER_NAME155
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME156
    |624810PROCNAME001ZZZ170SERVER_NAME157
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME158
    624810PROCNAME001ZZZ4SERVER_NAME159
    624810PROCNAME001ZZZ4SERVER_NAME160
    624810PROCNAME001ZZZ4SERVER_NAME161
    QUERY PLAN FOR STATEMENT 10 (at line 57).628910PROCNAME001ZZZ1SERVER_NAME162
    624810PROCNAME001ZZZ4SERVER_NAME163
    624810PROCNAME001ZZZ4SERVER_NAME164
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME165
    The type of query is INSERT.1026210PROCNAME001ZZZ1SERVER_NAME166
    624810PROCNAME001ZZZ4SERVER_NAME167
    4 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME168
    624810PROCNAME001ZZZ4SERVER_NAME169
    |ROOT:EMIT Operator (VA = 4)624810PROCNAME001ZZZ169SERVER_NAME170
    |624810PROCNAME001ZZZ170SERVER_NAME171
    |   |INSERT Operator (VA = 3)624810PROCNAME001ZZZ116SERVER_NAME172
    |   |  The update mode is direct.620410PROCNAME001ZZZ5SERVER_NAME173
    |   |624810PROCNAME001ZZZ123SERVER_NAME174
    |   |   |HASH DISTINCT Operator (VA = 2)624810PROCNAME001ZZZ113SERVER_NAME175
    |   |   | Using Worktable1 for internal storage.1026310PROCNAME001ZZZ1SERVER_NAME176
    |   |   |  Key Count: 6624810PROCNAME001ZZZ118SERVER_NAME177
    |   |   |624810PROCNAME001ZZZ123SERVER_NAME178
    |   |   |   |RESTRICT Operator (VA = 1)(0)(2)(0)(0)(3)624810PROCNAME001ZZZ128SERVER_NAME179
    |   |   |   |624810PROCNAME001ZZZ123SERVER_NAME180
    |   |   |   |   |SCAN Operator (VA = 0)624810PROCNAME001ZZZ132SERVER_NAME181
    |   |   |   |   |  FROM TABLE621510PROCNAME001ZZZ2SERVER_NAME182
    |   |   |   |   |  netting..order_alloc_link621710PROCNAME001ZZZ5SERVER_NAME183
    |   |   |   |   |  oo621710PROCNAME001ZZZ6SERVER_NAME184
    |   |   |   |   |  Using Clustered Index.622410PROCNAME001ZZZ3SERVER_NAME185
    |   |   |   |   |  Index : XPK_order_alloc_link622510PROCNAME001ZZZ1SERVER_NAME186
    |   |   |   |   |  Forward Scan.627610PROCNAME001ZZZ2SERVER_NAME187
    |   |   |   |   |  Positioning at index start.628210PROCNAME001ZZZ2SERVER_NAME188
    |   |   |   |   |  Index contains all needed columns. Base table will not be read.628610PROCNAME001ZZZ1SERVER_NAME189
    |   |   |   |   |  Using I/O Size 16 Kbytes for index leaf pages.627210PROCNAME001ZZZ2SERVER_NAME190
    |   |   |   |   |  With LRU Buffer Replacement Strategy for index leaf pages.627310PROCNAME001ZZZ5SERVER_NAME191
    |   |624810PROCNAME001ZZZ106SERVER_NAME192
    |   |  TO TABLE621410PROCNAME001ZZZ2SERVER_NAME193
    |   |  resonvloader_event_queue621710PROCNAME001ZZZ4SERVER_NAME194
    |   |  Using I/O Size 2 Kbytes for data pages.1024010PROCNAME001ZZZ4SERVER_NAME195
    624810PROCNAME001ZZZ4SERVER_NAME196
    624810PROCNAME001ZZZ4SERVER_NAME197
    624810PROCNAME001ZZZ4SERVER_NAME198
    QUERY PLAN FOR STATEMENT 11 (at line 69).628910PROCNAME001ZZZ1SERVER_NAME199
    624810PROCNAME001ZZZ4SERVER_NAME200
    624810PROCNAME001ZZZ4SERVER_NAME201
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME202
    The type of query is COND.1026210PROCNAME001ZZZ1SERVER_NAME203
    624810PROCNAME001ZZZ4SERVER_NAME204
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME205
    624810PROCNAME001ZZZ4SERVER_NAME206
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME207
    |624810PROCNAME001ZZZ170SERVER_NAME208
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME209
    624810PROCNAME001ZZZ4SERVER_NAME210
    624810PROCNAME001ZZZ4SERVER_NAME211
    624810PROCNAME001ZZZ4SERVER_NAME212
    QUERY PLAN FOR STATEMENT 12 (at line 71).628910PROCNAME001ZZZ1SERVER_NAME213
    624810PROCNAME001ZZZ4SERVER_NAME214
    624810PROCNAME001ZZZ4SERVER_NAME215
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME216
    The type of query is INSERT.1026210PROCNAME001ZZZ1SERVER_NAME217
    624810PROCNAME001ZZZ4SERVER_NAME218
    4 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME219
    624810PROCNAME001ZZZ4SERVER_NAME220
    |ROOT:EMIT Operator (VA = 4)624810PROCNAME001ZZZ169SERVER_NAME221
    |624810PROCNAME001ZZZ170SERVER_NAME222
    |   |INSERT Operator (VA = 3)624810PROCNAME001ZZZ116SERVER_NAME223
    |   |  The update mode is direct.620410PROCNAME001ZZZ5SERVER_NAME224
    |   |624810PROCNAME001ZZZ123SERVER_NAME225
    |   |   |HASH DISTINCT Operator (VA = 2)624810PROCNAME001ZZZ113SERVER_NAME226
    |   |   | Using Worktable1 for internal storage.1026310PROCNAME001ZZZ1SERVER_NAME227
    |   |   |  Key Count: 6624810PROCNAME001ZZZ118SERVER_NAME228
    |   |   |624810PROCNAME001ZZZ123SERVER_NAME229
    |   |   |   |RESTRICT Operator (VA = 1)(0)(2)(0)(0)(5)624810PROCNAME001ZZZ128SERVER_NAME230
    |   |   |   |624810PROCNAME001ZZZ123SERVER_NAME231
    |   |   |   |   |SCAN Operator (VA = 0)624810PROCNAME001ZZZ132SERVER_NAME232
    |   |   |   |   |  FROM TABLE621510PROCNAME001ZZZ2SERVER_NAME233
    |   |   |   |   |  netting..trade_allocation621710PROCNAME001ZZZ5SERVER_NAME234
    |   |   |   |   |  oo621710PROCNAME001ZZZ6SERVER_NAME235
    |   |   |   |   |  Index : inc1_trade_allocation622510PROCNAME001ZZZ1SERVER_NAME236
    |   |   |   |   |  Forward Scan.627610PROCNAME001ZZZ2SERVER_NAME237
    |   |   |   |   |  Positioning at index start.628210PROCNAME001ZZZ2SERVER_NAME238
    |   |   |   |   |  Index contains all needed columns. Base table will not be read.628610PROCNAME001ZZZ1SERVER_NAME239
    |   |   |   |   |  Using I/O Size 16 Kbytes for index leaf pages.627210PROCNAME001ZZZ2SERVER_NAME240
    |   |   |   |   |  With LRU Buffer Replacement Strategy for index leaf pages.627310PROCNAME001ZZZ5SERVER_NAME241
    |   |624810PROCNAME001ZZZ106SERVER_NAME242
    |   |  TO TABLE621410PROCNAME001ZZZ2SERVER_NAME243
    |   |  resonvloader_event_queue621710PROCNAME001ZZZ4SERVER_NAME244
    |   |  Using I/O Size 2 Kbytes for data pages.1024010PROCNAME001ZZZ4SERVER_NAME245
    624810PROCNAME001ZZZ4SERVER_NAME246
    624810PROCNAME001ZZZ4SERVER_NAME247
    624810PROCNAME001ZZZ4SERVER_NAME248
    QUERY PLAN FOR STATEMENT 13 (at line 82).628910PROCNAME001ZZZ1SERVER_NAME249
    624810PROCNAME001ZZZ4SERVER_NAME250
    624810PROCNAME001ZZZ4SERVER_NAME251
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME252
    The type of query is SELECT.1026210PROCNAME001ZZZ1SERVER_NAME253
    624810PROCNAME001ZZZ4SERVER_NAME254
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME255
    624810PROCNAME001ZZZ4SERVER_NAME256
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME257
    |624810PROCNAME001ZZZ170SERVER_NAME258
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME259
    624810PROCNAME001ZZZ4SERVER_NAME260
    624810PROCNAME001ZZZ4SERVER_NAME261
    624810PROCNAME001ZZZ4SERVER_NAME262
    QUERY PLAN FOR STATEMENT 14 (at line 84).628910PROCNAME001ZZZ1SERVER_NAME263
    624810PROCNAME001ZZZ4SERVER_NAME264
    624810PROCNAME001ZZZ4SERVER_NAME265
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME266
    The type of query is COND.1026210PROCNAME001ZZZ1SERVER_NAME267
    624810PROCNAME001ZZZ4SERVER_NAME268
    1 operator(s) under root624810PROCNAME001ZZZ167SERVER_NAME269
    624810PROCNAME001ZZZ4SERVER_NAME270
    |ROOT:EMIT Operator (VA = 1)624810PROCNAME001ZZZ169SERVER_NAME271
    |624810PROCNAME001ZZZ170SERVER_NAME272
    |   |SCALAR Operator (VA = 0)624810PROCNAME001ZZZ151SERVER_NAME273
    624810PROCNAME001ZZZ4SERVER_NAME274
    624810PROCNAME001ZZZ4SERVER_NAME275
    624810PROCNAME001ZZZ4SERVER_NAME276
    QUERY PLAN FOR STATEMENT 15 (at line 86).628910PROCNAME001ZZZ1SERVER_NAME277
    624810PROCNAME001ZZZ4SERVER_NAME278
    624810PROCNAME001ZZZ4SERVER_NAME279
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME280
    The type of query is ROLLBACK TRANSACTION.620310PROCNAME001ZZZ2SERVER_NAME281
    624810PROCNAME001ZZZ4SERVER_NAME282
    624810PROCNAME001ZZZ4SERVER_NAME283
    QUERY PLAN FOR STATEMENT 16 (at line 87).628910PROCNAME001ZZZ1SERVER_NAME284
    624810PROCNAME001ZZZ4SERVER_NAME285
    624810PROCNAME001ZZZ4SERVER_NAME286
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME287
    The type of query is PRINT.620310PROCNAME001ZZZ2SERVER_NAME288
    624810PROCNAME001ZZZ4SERVER_NAME289
    624810PROCNAME001ZZZ4SERVER_NAME290
    QUERY PLAN FOR STATEMENT 17 (at line 91).628910PROCNAME001ZZZ1SERVER_NAME291
    624810PROCNAME001ZZZ4SERVER_NAME292
    624810PROCNAME001ZZZ4SERVER_NAME293
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME294
    The type of query is COMMIT TRANSACTION.620310PROCNAME001ZZZ2SERVER_NAME295
    624810PROCNAME001ZZZ4SERVER_NAME296
    624810PROCNAME001ZZZ4SERVER_NAME297
    QUERY PLAN FOR STATEMENT 18 (at line 93).628910PROCNAME001ZZZ1SERVER_NAME298
    624810PROCNAME001ZZZ4SERVER_NAME299
    624810PROCNAME001ZZZ4SERVER_NAME300
    STEP 1620110PROCNAME001ZZZ1SERVER_NAME301
    The type of query is PRINT.620310PROCNAME001ZZZ2SERVER_NAME302
    624810PROCNAME001ZZZ4SERVER_NAME303
    Parse and Compile Time 0.361310PROCNAME001ZZZ0SERVER_NAME304
    Adaptive Server cpu time: 0 ms.010PROCNAME0null1SERVER_NAME305
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME10null1SERVER_NAME306
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME11null1SERVER_NAME307
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME23null1SERVER_NAME308
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME26null1SERVER_NAME309
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME41null1SERVER_NAME310
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME55null1SERVER_NAME311
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME69null1SERVER_NAME312
    Table: resonvloader_event_queue scan count 0, logical reads: (regular=9149872 apf=0 total=9149872), physical reads: (regular=0 apf=0 total=0), apf IOs used=0361510PROCNAME7101ZZZ0SERVER_NAME313
    Table: Worktable1 scan count 1, logical reads: (regular=26236 apf=0 total=26236), physical reads: (regular=24392 apf=0 total=24392), apf IOs used=0361510PROCNAME7101ZZZ0SERVER_NAME314
    Table: netting..trade_allocation (oo) scan count 1, logical reads: (regular=15060 apf=0 total=15060), physical reads: (regular=1890 apf=0 total=1890), apf IOs used=0361510PROCNAME7101ZZZ0SERVER_NAME315
    Total writes for this command: 3457361410PROCNAME7101ZZZ0SERVER_NAME316
    Execution Time 334.361210PROCNAME7101ZZZ0SERVER_NAME317
    Adaptive Server cpu time: 33400 ms.  Adaptive Server elapsed time: 51826 ms.010PROCNAME71null1SERVER_NAME318
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME82null1SERVER_NAME319
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 3 ms.010PROCNAME84null1SERVER_NAME320
    Total writes for this command: 12242361410PROCNAME9101ZZZ0SERVER_NAME321
    Execution Time 3.361210PROCNAME9101ZZZ0SERVER_NAME322
    Adaptive Server cpu time: 300 ms.  Adaptive Server elapsed time: 3593 ms.010PROCNAME91null1SERVER_NAME323
    Total number of events generated is : 992188010PROCNAME93null1SERVER_NAME324
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 0 ms.010PROCNAME93null1SERVER_NAME325
    Adaptive Server cpu time: 0 ms.  Adaptive Server elapsed time: 3 ms.010null3null1SERVER_NAME326
  • Sybase??

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • ChrisM@Work - Thursday, March 23, 2017 9:52 AM

    Sybase??

    yes

  • savibp3 - Thursday, March 23, 2017 10:05 AM

    ChrisM@Work - Thursday, March 23, 2017 9:52 AM

    Sybase??

    yes

    This is the v2012 section of a SQL Server forum. Have you tried posting in a Sybase forum? You might get lucky here but it's a long shot.

    “Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Sorry, I don't know Sybase.

    This forum is for Microsoft SQL Server. You might be better off tracking down a forum for Sybase.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 12 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic. Login to reply