Upgrade to Pro — share decks privately, control downloads, hide ads and more …

アーキテクチャから学ぶ分散SQL TiDB の強み・弱み

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
Avatar for Yukio Yukio
August 17, 2025

アーキテクチャから学ぶ分散SQL TiDB の強み・弱み

Avatar for Yukio

Yukio

August 17, 2025
Tweet

Other Decks in Programming

Transcript

  1. RDBのデータの持ち方 (データ複製時) id 1 … 1000 1001 … 2000 2001

    … 3000 users Table Master Replica 1 Replica 2 複製 複製
  2. id 1 … 1000 1001 … 2000 2001 … 3000

    ★Leader users Table TiKV Node A Follower ★Leader TiKV Node B Follower Follower Follower TiKV Node C ★Leader Follower TiKV Node D Follower TiDBのデータの持ち方 (データ分割 & 複製が基本系)
  3. クエリ実行時の挙動 (INSERT文) id 1 … 1000 1001 … 2000 ★Leader

    ★Leader users Table TiKV Node A TiKV Node B ① INSERT users (id) VALUES (5); ②log replication ③commit ③commit
  4. クエリ実行時の挙動 (INSERT文) id 1 … 1000 1001 … 2000 ★Leader

    ★Leader users Table TiKV Node A TiKV Node B ① INSERT users (id) VALUES (1005); ②log replication ③commit ③commit
  5. クエリ実行時の挙動 (SELECT文) id 1 … 1000 1001 … 2000 ★Leader

    ★Leader users Table TiKV Node A TiKV Node B ① SELECT * FROM users WHERE id = 5;
  6. クエリ実行時の挙動 (SELECT文) id 1 … 1000 1001 … 2000 ★Leader

    ★Leader users Table TiKV Node A TiKV Node B ① SELECT * FROM users WHERE id = 1005;
  7. クエリ実行時の挙動 (SELECT文) id 1 … 1000 1001 … 2000 ★Leader

    ★Leader users Table TiKV Node A TiKV Node B ① SELECT * FROM users
  8. TiDBの強み (2) レコードのバージョン管理を元にした機能 ・タイムトラベルクエリ SELECT ... FROM ... AS OF

    $(timestamp) ・DROPしたオブジェクト(Table / Database)のFLASHBACK FLASHBACK DATABASE $(db_name)
  9. TiDBの弱み (1) ミリ秒レベルでのレイテンシ増 id 1 … 1000 1001 … 2000

    ★Leader ★Leader users Table TiKV Node A TiKV Node B SELECT * FROM users
  10. TiDBの弱み (3) オートインクリメント時のホットスポット問題 id 1 … 1000 1001 … 2000

    ★Leader ★Leader users Table TiKV Node A TiKV Node B INSERT users (id) VALUES (5); INSERT users (id) VALUES (6);
  11. Q 「テナントごとにDBインスタンスを作成するインスタンス分離した DBを1つのTiDBクラスタで管理する場合 データの持ち方はどうなるのか? 」 A. MySQLではDatabaseはSQL ServerでいうところのSchemaに相当します。 TiDBクラスタで複数DBを運用する際は、テナントごとに Schema(Database)を作成し、そこにテーブルデータを

    作成していくことを想定しています。 したがって、論理的には Databaseごとにデータは別れますが、 物理的なデータ配置としては同じ TiKVノードに 別々のテナントのデータが同居する可能性 があります。 ★ t1.users TiKV Node A t1.users ★t2.users TiKV Node B t3.users t1.users t2.users TiKV Node C ★t3.users t2.users TiKV Node D t3.users