3

I have the following table with HUGE amount of data, this is why I want to split or partition it. The problem is I want to partition by a column that is no primary key: project_id. In my case there will be MAXIMUM 2 or 3 different project ids...

- id (PRIMARY KEY, AUTO INCREMENT)
- project_id (INT)
- username (UNIQUE)
- username_md5 (UNIQUE)
(- ... more but irrelevant columns)

As you can see I have 3 columns that I need to guarantee to be UNIQUE (id, username, username_md5). Now, I would like to do a RANGE partitioning on the project_id column. The only solution that I came up with is making an ugly 4-Column PRIMARY KEY for all those columns (Partitioning requires that all columns in the partitioning expression must be part of every unique key).

Now, I'm wondering

A) is a 4-column primary key just fine and usable?

B) is there a better solution for my partitioning?

C) otherwise I would do it manually by creating a "dynamic" table for each project_id that I have, might this be the easiest solution?

4

1 に答える 1

1

プライマリ/一意のキーを削除して単純なキーにすることができます.project_idで単純な範囲パーティションを作成するよりも、キーである必要があります

これらのフィールドはインデックス化されているため、高速アクセスが可能です。

一意性を保持したい場合があります。

  • アプリケーション層でそれを行う
  • 選択したネストされた挿入を使用してそれを行います
  • 一意の制約が追加された追加のテーブルを使用できます(組み合わせのみ)、テーブル内の組み合わせへの参照を保持します
于 2013-03-07T10:09:35.150 に答える