Yet Another "Detect Cardinality" Misbehavior

Hi,
Going through the various existing topics on Cardinality, I come to understand that it is better to set the cardinalities manually for the joins, based on the Data Model.
I have recently made an enhancement in a Universe, and added new fact table. Before setting the cardinalities manually, did an auto-detect to study the behavior.
Each of the facts has a relation with one of the Dimension tables based on 2 columns, i.e. 2 joins with same dim. The existing fact tables, on auto-detect gave the correct 1:N cardinality. But when performed for new fact table, for each of these 2 joins, it gave N:N… Though I have set the correct cardinality manually, was just wondering WHY! :roll_eyes:


mehak83 (BOB member since 2011-06-28)

Hi,

Cardinality detection runs 3 queries of this type:

  1. select count(*) from table A
  2. select count(*) from table B
  3. select count(*) from table A, B where …join between A and B…

Based on the 3 numbers it gets, Designer decides what the cardinality of a join can be.

As you can see, it’s just an estimate. If you have a fact table that is not populated right now or has only a sample of data, it can happen that the fact table has less rows than a dimension table and the cardinality detection algorithm gives incorrect result.

So, it’s always better to set the join cardinalities manually than to depend on the above algorithm.


Marek Chladny :slovakia: (BOB member since 2003-11-27)

Thanks Marek. That helped… :slight_smile:


mehak83 (BOB member since 2011-06-28)

I am facing an issue, while detecting the cardinality it shows me “Unknown Cardinality”.

When I executed the 3 sql queries as desribed by Marek I got the output as below.
Query 1 : 7
Query 2 : 4
Query 3 : 4

So is it M-M relation?


chetan86 :india: (BOB member since 2011-01-18)

Chetan,

As Marek says, don’t bother checking cardinalities. Refer to the data schema/database designer and ask them what the cardinalities are.

With that small set of data I certainly wouldn’t be guessing :wink: .

Agreed!


Mak 1 :uk: (BOB member since 2005-01-06)