![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
#4
| |||
| |||
|
To answer your other question, a qualified "yes" lower is better - in thesense that the ASE optimizer will seek to minimise this value in choosing the final plan. It's possible in practice, though, that the plan producing the fastest response to your query might not be the same as the one giving the lowest *estiamted* io cost. ![]() |
#5
| |||
| |||
|
|
On Oct 25, 6:21*pm, Antony <albion26.... (AT) gmail (DOT) com> wrote: To answer your other question, a qualified "yes" lower is better - in the sense that the ASE optimizer will seek to minimise this value in choosing the final plan. It's possible in practice, though, that the plan producing the fastest response to your query might not be the same as the one giving the lowest *estiamted* io cost. ![]() You're correct. (1) has the lower *estimate* and the slower time. Where as (2) has the higher *estimate* and the faster time. It's always interesting because "things" make sense... and here comes the wrench. (1) Total estimated I/O cost for statement 1 (at line 1): 20019. vs. (2) Total estimated I/O cost for statement 1 (at line 1): 63543. |
#6
| |||
| |||
|
|
(1) Total estimated I/O cost for statement 1 (at line 1): 20019. vs. (2) Total estimated I/O cost for statement 1 (at line 1): 63543. In the query plan for (2), "Index contains all needed columns. Base table will not be read." The estimate was higher and the time was faster. Positioning by key. Index contains all needed columns. Base table will not be read. Keys are: In the query plan for (1), it didn't have the "Index contains all needed columns. Base table will not be read." The estimate was lower and the time was slower. Positioning by key. Keys are: |
|
I guess, I'll have to put together the tables, queries and plan and post it. |
#7
| |||
| |||
|
|
ROOT:EMIT Operator (VA = 5) |RESTRICT Operator (VA = 4)(0)(0)(0)(0)(11) | | |MERGE JOIN Operator (Join Type: Left Outer Join) (VA = 3) | | Using Worktable2 for internal storage. | | Key Count: 1 | | Key Ordering: ASC | | | | |SORT Operator (VA = 1) | | | Average Row width is 22.000000 | | | Using Worktable1 for internal storage. | | | | | | |SCAN Operator (VA = 0) | | | | FROM TABLE | | | | first | | | | a | | | | Using Clustered Index. | | | | Index : first_pkc_1 | | | | Forward Scan. | | | | Positioning by key. | | | | Keys are: | | | | one_id ASC | | | | two_id ASC | | | | date ASC | | | | Using I/O Size 16 Kbytes for data pages. | | | | With MRU Buffer Replacement Strategy for data pages. | | | | |SCAN Operator (VA = 2) | | | FROM TABLE | | | second | | | b | | | Using Clustered Index. | | | Index : XPKsecone | | | 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. |
#8
| |||||
| |||||
|
|
Hopefully, this helps out? |
|
select * a.one_id, * a.two_id, * a.date, * b.junk_id from * first a * * left join second b on a.junk_id = b.junk_id |
|
* * * *| * | * | * |SCAN Operator (VA = 2) * * * *| * | * | * | *FROM TABLE * * * *| * | * | * | *second * * * *| * | * | * | *b * * * *| * | * | * | *Using Clustered Index. * * * *| * | * | * | *Index : XPKsecone |
|
* * * *| * | * | * | *Index contains all needed columns. Base table will not be read. |
|
Total estimated I/O cost for statement 1 (at line 1): 77052. The first table is filled with about 300 million records and the second table is filled with about 2 million records. According to the show plan, we it is using work tables and what do work tables mean? "Using Worktable2 for internal storage." and "Using Worktable1 for internal storage." Is there anything I can do to get rid of the work tables? |
#9
| |||
| |||
|
|
| | |MERGE JOIN Operator (Join Type: Left Outer Join) (VA = 3) |

#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |