Skip to content

Commit 0a84326

Browse files
jiangke-srkejiang
andauthored
Modify name length and delete unique constraint for index (milvus-io#18685) (milvus-io#18687)
Signed-off-by: kejiang <[email protected]> Signed-off-by: kejiang <[email protected]> Co-authored-by: kejiang <[email protected]>
1 parent 80543cb commit 0a84326

File tree

1 file changed

+20
-32
lines changed

1 file changed

+20
-32
lines changed

scripts/sql/meta.sql

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CREATE TABLE if not exists milvus_meta.collections (
1414
id BIGINT NOT NULL AUTO_INCREMENT,
1515
tenant_id VARCHAR(128) DEFAULT NULL,
1616
collection_id BIGINT NOT NULL,
17-
collection_name VARCHAR(128),
17+
collection_name VARCHAR(256),
1818
description VARCHAR(2048) DEFAULT NULL,
1919
auto_id BOOL DEFAULT FALSE,
2020
shards_num INT,
@@ -25,8 +25,7 @@ CREATE TABLE if not exists milvus_meta.collections (
2525
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
2626
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
2727
PRIMARY KEY (id),
28-
UNIQUE (tenant_id, collection_id, ts),
29-
INDEX idx_collection_id_ts (collection_id, ts)
28+
UNIQUE KEY uk_tenant_id_collection_id_ts (tenant_id, collection_id, ts)
3029
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
3130

3231
-- collection aliases
@@ -40,9 +39,8 @@ CREATE TABLE if not exists milvus_meta.collection_aliases (
4039
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
4140
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
4241
PRIMARY KEY (id),
43-
UNIQUE (tenant_id, collection_alias, ts),
44-
INDEX idx_tenant_id_collection_id_ts (tenant_id, collection_id, ts),
45-
INDEX idx_collection_id_ts (collection_id, ts)
42+
UNIQUE KEY uk_tenant_id_collection_alias_ts (tenant_id, collection_alias, ts),
43+
INDEX idx_tenant_id_collection_id_ts (tenant_id, collection_id, ts)
4644
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
4745

4846
-- channels
@@ -58,17 +56,16 @@ CREATE TABLE if not exists milvus_meta.collection_channels (
5856
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
5957
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
6058
PRIMARY KEY (id),
61-
UNIQUE (tenant_id, collection_id, virtual_channel_name, ts),
62-
INDEX idx_tenant_id_collection_id_ts (tenant_id, collection_id, ts),
63-
INDEX idx_collection_id_ts (collection_id, ts)
59+
UNIQUE KEY uk_tenant_id_collection_id_virtual_channel_name_ts (tenant_id, collection_id, virtual_channel_name, ts),
60+
INDEX idx_tenant_id_collection_id_ts (tenant_id, collection_id, ts)
6461
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
6562

6663
-- fields
6764
CREATE TABLE if not exists milvus_meta.field_schemas (
6865
id BIGINT NOT NULL AUTO_INCREMENT,
6966
tenant_id VARCHAR(128) DEFAULT NULL,
7067
field_id BIGINT NOT NULL,
71-
field_name VARCHAR(128) NOT NULL,
68+
field_name VARCHAR(256) NOT NULL,
7269
is_primary_key BOOL NOT NULL,
7370
description VARCHAR(2048) DEFAULT NULL,
7471
data_type INT UNSIGNED NOT NULL,
@@ -81,27 +78,25 @@ CREATE TABLE if not exists milvus_meta.field_schemas (
8178
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
8279
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
8380
PRIMARY KEY (id),
84-
UNIQUE (tenant_id, collection_id, field_name, ts),
85-
INDEX idx_tenant_id_collection_id_field_id_ts (tenant_id, collection_id, field_id, ts),
86-
INDEX idx_collection_id_field_id_ts (collection_id, field_id, ts)
81+
UNIQUE KEY uk_tenant_id_collection_id_field_name_ts (tenant_id, collection_id, field_name, ts),
82+
INDEX idx_tenant_id_collection_id_field_id_ts (tenant_id, collection_id, field_id, ts)
8783
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
8884

8985
-- partitions
9086
CREATE TABLE if not exists milvus_meta.`partitions` (
9187
id BIGINT NOT NULL AUTO_INCREMENT,
9288
tenant_id VARCHAR(128) DEFAULT NULL,
9389
partition_id BIGINT NOT NULL,
94-
partition_name VARCHAR(128),
90+
partition_name VARCHAR(256),
9591
partition_created_timestamp bigint unsigned,
9692
collection_id BIGINT NOT NULL,
9793
ts BIGINT UNSIGNED DEFAULT 0,
9894
is_deleted BOOL DEFAULT FALSE,
9995
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
10096
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
10197
PRIMARY KEY (id),
102-
UNIQUE (tenant_id, collection_id, partition_name, ts),
103-
INDEX idx_tenant_id_collection_id_partition_id_ts (tenant_id, collection_id, partition_id, ts),
104-
INDEX idx_collection_id_partition_id_ts (collection_id, partition_id, ts)
98+
UNIQUE KEY uk_tenant_id_collection_id_partition_name_ts (tenant_id, collection_id, partition_name, ts),
99+
INDEX idx_tenant_id_collection_id_partition_id_ts (tenant_id, collection_id, partition_id, ts)
105100
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
106101

107102
-- indexes
@@ -111,16 +106,14 @@ CREATE TABLE if not exists milvus_meta.`indexes` (
111106
field_id BIGINT NOT NULL,
112107
collection_id BIGINT NOT NULL,
113108
index_id BIGINT NOT NULL,
114-
index_name VARCHAR(128),
109+
index_name VARCHAR(256),
115110
index_params VARCHAR(2048),
116111
create_time bigint unsigned,
117112
is_deleted BOOL DEFAULT FALSE,
118113
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
119114
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
120115
PRIMARY KEY (id),
121-
UNIQUE (tenant_id, collection_id, index_name),
122-
INDEX idx_tenant_id_collection_id_index_id (tenant_id, collection_id, index_id),
123-
INDEX idx_collection_id_index_id (collection_id, index_id)
116+
INDEX idx_tenant_id_collection_id_index_id (tenant_id, collection_id, index_id)
124117
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
125118

126119
-- index file paths
@@ -133,8 +126,7 @@ CREATE TABLE if not exists milvus_meta.index_file_paths (
133126
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
134127
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
135128
PRIMARY KEY (id),
136-
INDEX idx_tenant_id_index_build_id (tenant_id, index_build_id),
137-
INDEX idx_index_build_id (index_build_id)
129+
INDEX idx_tenant_id_index_build_id (tenant_id, index_build_id)
138130
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
139131

140132
-- segments
@@ -158,8 +150,7 @@ CREATE TABLE if not exists milvus_meta.segments (
158150
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
159151
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
160152
PRIMARY KEY (id),
161-
INDEX idx_tenant_id_collection_id_segment_id (tenant_id, collection_id, segment_id),
162-
INDEX idx_collection_id_segment_id (collection_id, segment_id)
153+
INDEX idx_tenant_id_collection_id_segment_id (tenant_id, collection_id, segment_id)
163154
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
164155

165156
-- segment indexes
@@ -182,9 +173,8 @@ CREATE TABLE if not exists milvus_meta.segment_indexes (
182173
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
183174
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
184175
PRIMARY KEY (id),
185-
UNIQUE (tenant_id, segment_id, index_id),
186-
INDEX idx_tenant_id_collection_id_segment_id_index_id (tenant_id, collection_id, segment_id, index_id),
187-
INDEX idx_collection_id_segment_id_index_id (collection_id, segment_id, index_id)
176+
UNIQUE KEY uk_tenant_id_segment_id_index_id (tenant_id, segment_id, index_id),
177+
INDEX idx_tenant_id_collection_id_segment_id_index_id (tenant_id, collection_id, segment_id, index_id)
188178
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
189179

190180
-- binlog files info
@@ -204,8 +194,7 @@ CREATE TABLE if not exists milvus_meta.binlogs (
204194
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
205195
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
206196
PRIMARY KEY (id),
207-
INDEX idx_tenant_id_segment_id_log_type (tenant_id, segment_id, log_type),
208-
INDEX idx_segment_id_log_type (segment_id, log_type)
197+
INDEX idx_tenant_id_segment_id_log_type (tenant_id, segment_id, log_type)
209198
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
210199

211200
-- users
@@ -219,6 +208,5 @@ CREATE TABLE if not exists milvus_meta.credential_users (
219208
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
220209
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP on update current_timestamp,
221210
PRIMARY KEY (id),
222-
INDEX idx_tenant_id_username (tenant_id, username),
223-
INDEX idx_username (username)
211+
INDEX idx_tenant_id_username (tenant_id, username)
224212
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

0 commit comments

Comments
 (0)