[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference orarep::nomahs::rdb_60

Title:Oracle Rdb - Still a strategic database for DEC on Alpha AXP!
Notice:RDB_60 is archived, please use RDB_70..
Moderator:NOVA::SMITHISON
Created:Fri Mar 18 1994
Last Modified:Fri May 30 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:5118
Total number of notes:28246

5052.0. "Optimizer question about index suitability" by ukvms3.uk.oracle.com::LWILES (Louise Wiles, UK Rdb support) Thu Feb 20 1997 09:04

    Hi,

    Rdb V6.1-1 & Rdb7
    VMS V6.1

    I have a query which selects 4 columns from 1 table; these same 4
    columns are also used in the where clause.

    The table has 2 indexes, neither of which completely satisfy the query,
    so the dynamic optimizer is considering both.

    However, one index is much more suitable than the other in that 3 of
    the 4 columns in the query are used in the index definition.
    Could/should the optimizer get smarter in this case?

    The 2 indexes are both sorted, duplicates allowed.

    One is defined using 6 columns - 
    financial_year   *
    financial_week   *
    store_number     *
    product_group
    reference_no
    line_number

    the other has 4 segments -
    reference_no
    version
    sale_item         *
    line_number

    * shows the columns in the query.

    the 4 columns in the query are 
    financial_year
    financial_week
    store_number
    sale_item

    so 75% of the columns in the query appear in the 6 segment index, but
    only 25% in the 4 segment index.

    Thanks,
    Louise.
T.RTitleUserPersonal
Name
DateLines
5052.1NOVA::SMITHIDon't understate or underestimate Rdb!Thu Feb 20 1997 09:159
The optimizer algorithm tries to find the best index but the estimates don't
always allow a differentiation.

Please show us the index and query definitions (I am not sure the order of
columns you showed us was the same as in the database).

As always if you don't like it use a query outline.

ian
5052.2ukvms3.uk.oracle.com::LWILESLouise Wiles, UK Rdb supportThu Feb 20 1997 12:5940
    The index definitions are:
    
    SALE_ITEM_FINANCIAL             with column FINANCIAL_YEAR
                                    and column FINANCIAL_WEEK
                                    and column STORE_NUMBER
                                    and column PRODUCT_GROUP
                                    and column REFERENCE_NO
                                    and column LINE_NUMBER
      Duplicates are allowed
      Type is Sorted
      Compression is DISABLED
     Store clause:          STORE in sale_item_u3
    
    SALE_ITEM_INDEX1                with column REFERENCE_NO
                                    and column VERSION
                                    and column SALE_ITEM
                                    and column LINE_NUMBER
      Duplicates are allowed
      Type is Sorted
      Compression is DISABLED
    Store clause:           STORE in sale_item_u1
    
    The query is
    select financial_year, financial_week, store_number, sale_item
    from sale_items where
    financial_year = 1007 and financial_week = 25
    and store_number = 25 and sale_item = 'DGF1234';
    
    After thinking about this, I'm probably doing an injustice to Rdb7.
    
    I don't have the data in the table - I've set rdb$cardinality in
    rdb$relations & rdb$indices to emulate the problem. This is ok for
    V6.1, but I'd forgotten the new cardinality stuff in Rdb7.
    
    To check out Rdb7 properly, I assume I need to update rdb$cardinality
    in rdb$index_segments too, so for the sale_item_financial index, how
    would I calculate this value?
    
    Thanks,
    Louise.
5052.3What's the S output? BOUVS::OAKEYI'll take Clueless for $500, AlexThu Feb 20 1997 20:384
Also, what *is* the retrieval strategy?  You mention dynamic but not how 
it's used...

5052.4ukvms3.uk.oracle.com::LWILESLouise Wiles, UK Rdb supportFri Feb 21 1997 04:1423
    Here's the strategy:
    ~S#0001
    Leaf#01 Sorted SALE_ITEMS Card=44100158
      FgrNdx  SALE_ITEM_FINANCIAL [3:3] Fan=7
      BgrNdx1 SALE_ITEM_INDEX1 [0:0] Bool Fan=12
    ~E#0001.01(1) FgrNdx  Sorted   DBKeys=0  Fetches=0+0  RecsOut=0
    
    I'm not really questioning what the optimizer is doing - I see it as
    expected behaviour - just that if it's not worthwhile considering
    sale_item_index1, is it possible to add the heuristics to make it
    smarter in cases such as these?
    
    I have a customer with this scenario & I want to know if it's worth
    submitting a suggestion BUG.
    
    The table has several million rows, so the time taken to consider the
    sale_item_index1 index is noticable.
    
    Unfortunately, query outlines aren't an option in this case. The values
    in the where clause won't be constant, so named outlines would have to
    be used, and they're using SQL/Services which doesn't offer this.
    
    Louise.
5052.5NOVA::SMITHIDon't understate or underestimate Rdb!Fri Feb 21 1997 12:4531
~    I'm not really questioning what the optimizer is doing - I see it as
~    expected behaviour - just that if it's not worthwhile considering
~    sale_item_index1, is it possible to add the heuristics to make it
~    smarter in cases such as these?

I think you may not understand completely what the dynamic optimizer is doing. 
It starts a competition between the various background legs to see if the
other strategy will produce a better (i.e. more efficient) stream of dbkeys
for the query solution.  If the background is performing poorly it will be
aborted, and the partial results will still be valuable. So the heuristics are
already there...
    
~    I have a customer with this scenario & I want to know if it's worth
~    submitting a suggestion BUG.

I don't think so.
    
~    The table has several million rows, so the time taken to consider the
~    sale_item_index1 index is noticable.

This I don't understand, The strategy and execution trace you showed us didn't
even indicate the SALE_ITEM_INDEX1 was used, so how can it be "noticable"?
    
~    Unfortunately, query outlines aren't an option in this case. The values
~    in the where clause won't be constant, so named outlines would have to
~    be used, and they're using SQL/Services which doesn't offer this.

Are you saying the values in the where clause are literals?  Make them
host variables so that the query is constant.

Ian
5052.6BOUVS::OAKEYI'll take Clueless for $500, AlexFri Feb 21 1997 13:0016
~~  <<< Note 5052.5 by NOVA::SMITHI "Don't understate or underestimate Rdb!" >>>

~~This I don't understand, The strategy and execution trace you showed us didn't
~~even indicate the SALE_ITEM_INDEX1 was used, so how can it be "noticable"?

I read SALE_ITEM_INDEX1 as the Bgrndx1, but from the E output, not sure 
that it was used.

re:  earlier...

Just setting cardinalities isn't very productive when looking at dynamic 
optimizer output.  Depending on the strategies, actual I/Os are used to 
control behavior.  If all you do is tweak cardinalities, you'll affect how 
dynamic is set up, but the 'E' output will not accurately reflect 
application runtime behavior for each execution of the query.
    
5052.7Doesn't look too goodsvrav1.au.oracle.com::MBRADLEYI was dropped on my head as a baby. What&#039;s your excuse?Wed Feb 26 1997 21:0427
Louise,

>    ~S#0001
>    Leaf#01 Sorted SALE_ITEMS Card=44100158
>      FgrNdx  SALE_ITEM_FINANCIAL [3:3] Fan=7
>      BgrNdx1 SALE_ITEM_INDEX1 [0:0] Bool Fan=12
>    ~E#0001.01(1) FgrNdx  Sorted   DBKeys=0  Fetches=0+0  RecsOut=0

With the sorted leaf type, the forground index is always scanned to 
completion to provide the appropriate sorted sequence. The background 
process is scanning another index in the hope that it can build a dbkey 
list that it can pass to forground so that forground doesn't have to read 
all rows that it finds in the forground index scan, but rather only those 
that are also in the background dbkey list.

Since the background index scan has to scan the entire index ([0:0]), and 
is doing a key only boolean on one field, I doubt that this will be able to 
significantly reduce the dbkey list from the forground index scan ([3:3]).

So all in all, I suspect that the background index is a waste of time. But 
testing and measurement would be required to prove this. Do you have 
statistics that compare the above strategy with a static strategy just 
using SALE_ITEM_FINANCIAL?

G'day,

Mark.