Here is the IO summary for 12.5.3:
Table
Name Scans
LReads LR/Scan PReads
--------------- -----
------ -------
------
fund
1197 2476 2.07
0
invoice_account 1195
5206 4.36
0
pending_invoice 2340
9876 4.22 0
===============
{TOTALS}
4732 17558 3.71
0
Here is the IO summary for 15.0.2:
Table
Name Scans
LReads LR/Scan PReads
--------------- -----
------ ------- ------
fund 3
96 32.00
14
invoice_account 1195 5112
4.28
0
pending_invoice 6
3536 589.33 1320
===============
{TOTALS} 1204
8744 7.26 1334
So as you can see , 15.0.2 resulted in many fewer
(almost 1/2) logical reads, but 1,334 additional physical reads. That's
probably where your performance difference is.
The difference lies in the query plans generated
for line 25, and line 61/62:
UPDATE pending_invoice_v1
SET
fund_id = f.fundcode_fixed
from pending_invoice_v1 pi, fund..fund_v3
f
WHERE @invoice_id = pi.invoice_id
and
convert(char(10),f.cusip) =
pi.input_fund
UPDATE pending_invoice_v1
SET
fund_id = f.fundcode_fixed
from pending_invoice_v1 pi, fund..fund_v3
f
WHERE @invoice_id = pi.invoice_id
and
f.fundcode_fixed =
pi.input_fund
The plans below indicate that line 25 in 15.0.2
during the merge join uses only the first key in the pending_invoice index which
is invoice_id. The plan for line 61/62 in 15.0.2 scans the "fund_i1"
index, where the 12.5.3 optimizer uses the "fundcode_fixed" colum to key
position.
These are the 12.5.3 NLJ plans for the above two
statements:
=========================
QUERY PLAN FOR STATEMENT 9 (at line
25).
STEP
1
The type of query is
UPDATE.
The update mode is
deferred.
FROM
TABLE
fund
Nested
iteration.
Table
Scan.
Forward
scan.
Positioning at start of
table.
Using I/O Size 16 Kbytes
for data pages.
With LRU Buffer
Replacement Strategy for data pages.
FROM
TABLE
pending_invoice
Nested
iteration.
Index :
pending_invoice_i1
Forward
scan.
Positioning by
key.
Keys
are:
invoice_id
ASC
input_fund ASC
Using I/O
Size 16 Kbytes for index leaf
pages.
With LRU Buffer Replacement
Strategy for index leaf pages.
Using I/O Size 16 Kbytes for data
pages.
With LRU Buffer Replacement
Strategy for data pages.
TO
TABLE
pending_invoice
Using I/O Size 2
Kbytes for data pages.
QUERY PLAN FOR STATEMENT 21 (at line
61).
STEP
1
The type of query is
UPDATE.
The update mode is
deferred_varcol.
FROM
TABLE
pending_invoice
Nested
iteration.
Index :
pending_invoice_i1
Forward
scan.
Positioning by
key.
Keys
are:
invoice_id ASC
Using I/O
Size 16 Kbytes for index leaf
pages.
With LRU Buffer Replacement
Strategy for index leaf pages.
Using I/O Size 16 Kbytes for data
pages.
With LRU Buffer Replacement
Strategy for data pages.
FROM
TABLE
fund
EXISTS TABLE : nested
iteration.
Index :
fund_i5
Forward
scan.
Positioning by
key.
Index contains all needed
columns. Base table will not be
read.
Keys
are:
fundcode_fixed ASC
Using I/O
Size 2 Kbytes for index leaf
pages.
With LRU Buffer Replacement
Strategy for index leaf pages.
TO
TABLE
pending_invoice
Using I/O Size 2
Kbytes for data pages.
These are the 15.0.2 MJ plans:
=========================
QUERY PLAN FOR STATEMENT 9 (at line 25).
STEP
1
The type of query is
UPDATE.
6 operator(s) under root
|ROOT:EMIT
Operator
|
| |UPDATE
Operator
| | The
update mode is deferred.
|
|
| | |MERGE
JOIN Operator (Join Type: Inner Join)
| | | Using Worktable2 for internal
storage.
| |
| Key Count: 1
|
| | Key Ordering: ASC
| | |
| | | |SCAN
Operator
| |
| | FROM TABLE
| | | |
pending_invoice
|
| | | Index :
pending_invoice_i1
|
| | | Forward
Scan.
| |
| | Positioning by
key.
| |
| | Keys are:
| | | | invoice_id
ASC
| |
| | Using I/O Size 16 Kbytes for index leaf
pages.
| |
| | With LRU Buffer Replacement Strategy for index leaf
pages.
| |
| | Using I/O Size 16 Kbytes for data
pages.
| |
| | With MRU Buffer Replacement Strategy for data
pages.
| |
|
| |
| |SORT Operator
| | | | Using Worktable1 for internal
storage.
| |
| |
|
| | | |RESTRICT
Operator
| |
| | |
| | | | | |SCAN
Operator
| |
| | | | FROM
TABLE
| |
| | | |
fund
| |
| | | | Table
Scan.
| |
| | | | Forward
Scan.
| |
| | | | Positioning at start of
table.
| |
| | | | Using I/O Size 16 Kbytes for
data pages.
| |
| | | | With LRU Buffer Replacement
Strategy for data pages.
|
|
| | TO
TABLE
| |
pending_invoice
| |
Using I/O Size 2 Kbytes for data pages.
QUERY PLAN FOR STATEMENT 21 (at line 62).
STEP
1
The type of query is
UPDATE.
5 operator(s) under root
|ROOT:EMIT
Operator
|
| |UPDATE
Operator
| | The
update mode is deferred.
|
|
| | |MERGE
JOIN Operator (Join Type: Inner Join)
| | | Using Worktable1 for internal
storage.
| |
| Key Count: 1
|
| | Key Ordering: ASC
| | |
| | | |SCAN
Operator
| |
| | FROM TABLE
| | | |
pending_invoice
|
| | | Index :
pending_invoice_i1
|
| | | Forward
Scan.
| |
| | Positioning by
key.
| |
| | Keys are:
| | | | invoice_id
ASC
| |
| | Using I/O Size 16 Kbytes for index leaf
pages.
| |
| | With LRU Buffer Replacement Strategy for index leaf
pages.
| |
| | Using I/O Size 16 Kbytes for data
pages.
| |
| | With MRU Buffer Replacement Strategy for data
pages.
| |
|
| |
| |GROUP SORTED Operator
| | |
|Distinct
| |
| |
|
| | | |SCAN
Operator
| |
| | | FROM
TABLE
| |
| | | fund
| | | | | Index :
fund_i5
| |
| | | Forward
Scan.
| |
| | | Positioning at index
start.
| |
| | | Index contains all needed columns. Base
table will not be read.
|
| | | | Using I/O Size 16 Kbytes for
index leaf pages.
|
| | | | With LRU Buffer Replacement
Strategy for index leaf pages.
| |
| | TO
TABLE
| |
pending_invoice
| |
Using I/O Size 2 Kbytes for data pages.
> See attached files.
>
> Thanks Kevin!
>
> "Sherlock, Kevin" <kevin.s...@teamsybase.com>
wrote in message
> news:48286142$1@forums-1-dub...