wombat53 wrote:

All the literature states (as does Knut) that the Partitioning key

must be a subset of any uniq, primary keys etc. Is it also valid for

the partitioning key make-up to be identical to the column(s) of a

uniq or Prim Key also? i.e. Pr/UNIQ Key col(s)>= Partitioning key

col(s). Can they be identical, with an EQUAL number of columns? Is that

also valid?

Yes, the partitioning key can be identical to the primary key.

Does superset mean "contains all Part Key col(s), and a

column more", or does it mean "contains at least all Partitioning Key

columns...and may optionally contain more columns, as required"

I used the terms "subset" and "superset" in the mathematical sense, i.e. a

set is always a subset of itself (but not a proper or strict subset). So

yes, the partitioning key as a subset of the columns of the primary key can

be identical to the primary key.

The thing with the partitioning key is this: The verification for the

uniqueness of the primary key or any unique key is done locally on each

node. A row is taken, its partition determined and then the row is send to

the partition on which it is to be stored. There, the row is inserted into

the table and the index maintained (locally on the partition). For unique

constraints (a PK is just that), the uniqueness is ensured on based on the

data on the partition only, i.e. the partial index on the partition must

suffice to find possible duplicates or to make sure that there is no

duplicate. With such an approach, it is mandatory that all potential

duplicates are always stored on the same partition. Otherwise, the columns

in the partitioning key could have different values in different rows,

leading to the rows being distributed to different partitions. That can

only be ensured if the partitioning key is a part of _all_ unique

constraints/indexes.

If you have multiple independent unique constraints, you'll have to resort

to other mechanisms. For example, you could ensure uniqueness in a trigger

for those unique constraints that cannot be created due to the partitioning

key. (A non-unique index on those columns may be a good idea then.)

--

Knut Stolze

DB2 Information Integration Development

IBM Germany