Hello, I am having a bit of a mystery. I have a database which is almost identical on 2 different, identical servers with the same version (Adaptive Server Enterprise/16.0 SP02 PL01/EBF 25183 SMP/P/X64/Windows Server/ase160sp02p100/0/64-bit/FBO/). I am running the same query on both databases. The tables have identical structure and identical indexes. The query plans for the query is different. The top query plan is nearly instant, the bottom query plan takes about 6 minutes to run. I don't understand why it's using different plans. Help please!
Select RSISSet.*, RSC.Sequence as Sequence
from Table1 RSC
inner join Table2 RSISSet
on RSISSet.Field3= RSC.ContentId
where RSC.IndexRef2 = 1942454143 and ( RSISSet.Kind= -115 or RSISSet.Kind=-128 )
go
QUERY PLAN FOR STATEMENT 1 (at line 3).
Optimized using Serial Mode
STEP 1
The type of query is SELECT.
4 operator(s) under root
|ROOT:EMIT Operator (VA = 4)
|
| |NESTED LOOP JOIN Operator (VA = 3) (Join Type: Inner Join)
| |
| | |SCAN Operator (VA = 0)
| | | FROM TABLE
| | | Table1
| | | RSC
| | | Index : Table2Ref2Key
| | | Forward Scan.
| | | Positioning by key.
| | | Keys are:
| | | IndexRef2 ASC
| | | Using I/O Size 32 Kbytes for index leaf pages.
| | | With LRU Buffer Replacement Strategy for index leaf pages.
| | | Using I/O Size 32 Kbytes for data pages.
| | | With LRU Buffer Replacement Strategy for data pages.
| |
| | |RESTRICT Operator (VA = 2)(0)(0)(0)(7)(0)
| | |
| | | |SCAN Operator (VA = 1)
| | | | FROM TABLE
| | | | Table2
| | | | RSISSet
| | | | Index : RSField3Key
| | | | Forward Scan.
| | | | Positioning by key.
| | | | Keys are:
| | | | Field3 ASC
| | | | Using I/O Size 32 Kbytes for index leaf pages.
| | | | With LRU Buffer Replacement Strategy for index leaf pages.
| | | | Using I/O Size 32 Kbytes for data pages.
| | | | With LRU Buffer Replacement Strategy for data pages.
Total estimated I/O cost for statement 1 (at line 3): 2276580.
QUERY PLAN FOR STATEMENT 1 (at line 2).
Optimized using Serial Mode
STEP 1
The type of query is SELECT.
9 operator(s) under root
|ROOT:EMIT Operator (VA = 9)
|
| |SEQUENCER Operator (VA = 8) has 2 children.
| |
| | |STORE Operator (VA = 2)
| | | Worktable1 created, in allpages locking mode, for REFORMATTING.
| | | Creating clustered index.
| | |
| | | |INSERT Operator (VA = 1)
| | | | The update mode is direct.
| | | |
| | | | |SCAN Operator (VA = 0)
| | | | | FROM TABLE
| | | | | Table1
| | | | | RSC
| | | | | Index : Table2Ref2Key
| | | | | Forward Scan.
| | | | | Positioning by key.
| | | | | Keys are:
| | | | | IndexRef2 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
| | | | Worktable1.
| |
| | |NESTED LOOP JOIN Operator (VA = 7) (Join Type: Inner Join)
| | |
| | | |NESTED LOOP JOIN Operator (VA = 5) (Join Type: Inner Join)
| | | |
| | | | |SCAN Operator (VA = 3)
| | | | | FROM OR List
| | | | | OR List has up to 2 rows of OR/IN values.
| | | |
| | | | |SCAN Operator (VA = 4)
| | | | | FROM TABLE
| | | | | Table2
| | | | | RSISSet
| | | | | Index : RSKind_I
| | | | | Forward Scan.
| | | | | Positioning by key.
| | | | | Keys are:
| | | | | Kind ASC
| | | | | Using I/O Size 32 Kbytes for index leaf pages.
| | | | | With LRU Buffer Replacement Strategy for index leaf pages.
| | | | | Using I/O Size 32 Kbytes for data pages.
| | | | | With LRU Buffer Replacement Strategy for data pages.
| | |
| | | |SCAN Operator (VA = 6)
| | | | FROM TABLE
| | | | Worktable1.
| | | | Using Clustered Index.
| | | | Forward Scan.
| | | | Positioning by key.
| | | | Using I/O Size 4 Kbytes for data pages.
| | | | With LRU Buffer Replacement Strategy for data pages.
Total estimated I/O cost for statement 1 (at line 2): 3550013.