gpt4 book ai didi

Question on sharding using planetscale (keeping data within a country using sharding)(关于使用planetscale进行分片的问题(使用分片将数据保存在一个国家内))

转载 作者:bug小助手 更新时间:2023-10-22 14:28:34 26 4
gpt4 key购买 nike



I'm building a niche social media DB on planetscale that spans users living in multiple countries. Is there a way I can shard my social media user data per country and have that data physically located in the cloud region for that user's country? I need this solution to abide by the Data sovereignty laws. Please note: the dB needs to support queries spanning users in multiple countries (just like any social media use-case)

我正在建立一个小规模的社交媒体数据库,覆盖居住在多个国家的用户。有没有一种方法可以将我的社交媒体用户数据按国家划分,并将这些数据物理地放在该用户所在国家的云区域中?我需要这个解决方案来遵守数据主权法律。请注意:dB需要支持跨多个国家/地区用户的查询(就像任何社交媒体用例一样)


In planetscale I understand I have to select a primary region for my database, but I'm hoping that by using sharding and vitess I can shard the data into the respective region for that country.

在planetscale中,我知道我必须为我的数据库选择一个主要区域,但我希望通过使用sharding和vitess,我可以将数据划分到该国家的相应区域。


Is what I want to do even possible? I was hoping to include country code in the users and posts tables and shard by country:

我想做的事情有可能吗?我希望在用户和帖子表中包括国家代码,并按国家划分:


CREATE TABLE users (

CREATE TABLE用户(


id CHAR(18) NOT NULL,

id CHAR(18)不为空,


user_handle VARCHAR(20),

user_ handle VARCHAR(20),


country_code VARCHAR(2),

country_ code VARCHAR(2),


created_at TIMESTAMP,

created_ at TIMESTAMP,


PRIMARY KEY (id, country_code)

主键(id,country_code)


);

);


CREATE TABLE posts (

CREATE TABLE帖子(


id CHAR(18) NOT NULL,

id CHAR(18)不为空,


user_id CHAR(18) NOT NULL,

user_id CHAR(18)不为空,


text VARCHAR(280),

文本VARCHAR(280),


country_code VARCHAR(2),

country_ code VARCHAR(2),


created_at TIMESTAMP

创建时间戳


PRIMARY KEY (id, country_code)
);

PRIMARY KEY(id,country_code));


Planetscale doesn't offer sharding until the DB reaches a certain size and payment plan, so I'm unable to test this.

Planetscale在DB达到一定的规模和支付计划之前不会提供分片,所以我无法测试这一点。


更多回答
优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com