SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
2011 3   4




2011   3   5
•                  DB




       • Index
         Index                 Covering Index   Primary Key
           Read   Write


       • MySQL
                                DB                            SQL




2011   3   5
•


           →(10001,A)
           ※


       •
                          Primary Key
           →Primary Key


       •
                            Primary Key



2011   3   5
•




                            ID
                   ID
                        1
               1
                        2
               2
                        2




2011   3   5
•
                                             ID           ID

                                      1           10001

                                      1           10002

                                      2           10001
                   ID           ID

               1        10001         2           10002

               1        10002

               2        10001

               2        10002                ID

                                     10001

                                     10002




2011   3   5
•

                                        ID     ID
                               1             101
                               2             102
                   ID     ID   3             103

               1        101    4             102

               2        102

               3        103

               4        102        ID
                               101
                               102
                               103




2011   3   5
ALTER TABLE

       •


       •                            (ALTER TABLE)
           →ALTER TABLE


       •




       •


           →



2011   3   5
ID                         ID
                   1               1         101               1
                   1               2         234               2
                   1               3         553               3
                   1               4         232               4
                   2               1         102
                   2               2         271
                   2               3         952


                   ID
               1             101       234    553       232   873   0     102   0
               2             102       271    8652      98    0     234   202   0
               3             103       952     76       765   872   45     0    0
               4             102       197    2312      762   4     232   672   34



       •



2011   3   5
Index

       • WHERE                             Index     Primary Key

       WHERE user_id = 10001

       → user_id    Index(        Primary Key)

       WHERE user_id = 10001 AND friend_id = 10002

       → (user_id, friend_id)

       WHERE visiting_id = 10001 AND visited_id IN (1,2,3) AND action=2

       → (visiting_id,visited_id,action)

       WHERE status = 2 ORDER BY start_time

       → (status,start_time)


2011   3   5
Index

       •                  Index

       WHERE start_time < 12345678 AND state = 2

       →(start_time,state)                                    (state,start_time)

       • Index

       WHERE visited_id = 10002 AND visiting_id = 10001 AND action=2

       → (visiting_id,visited_id,action)


       •                             Index

       WHERE visiting_id = 10001 AND action = 2 AND visited_id = 10002

       → (visiting_id,visited_id,action)     Index   visiting_id


2011   3   5
Covering Index

       •

           MySQL                                         Covering Index   - ( ∀ )o   sasata299's blog
           http://blog.livedoor.jp/sasata299/archives/51336006.html



       •
                 Covering Index
           →




2011   3   5
Primary Key                                                 id

       •             Primary Key
           →                     Primary Key                    MySQL               id
           Primary Key
           MySQL :: MySQL 5.1                          :: 13.5.13 InnoDB
           http://dev.mysql.com/doc/refman/5.1/ja/innodb-table-and-index.html


       •        id              WHERE id IN (a,b,c,d...)


       •        id
                                              id
                                    Primary Key                                 (        Covering
           Index          )



2011   3   5
Primary Key

       •                                                   id        Primary Key
                                                                     1


                                             Primary Key


       •                                                        id


       •              id   Primary Key
           (“WHERE user_id=10001”        )




2011   3   5
auto_increment

       •


           ID

               CREATE TABLE seq_history(
                  seq_id bigint unsigned not null
               );

       • auto_increment
           MySQL5.1                                 DB
                 auto_increment




2011   3   5
Read       Write

       • Read(SELECT)       DB
               Write       DB              DB



       •           Write         SELECT



       •                          SELECT




       •                          Read
                                            Write

2011   3   5
•       Read/Write   SQL




       •
                                  IO




           →
           →




2011   3   5
MySQL

       •       DB                                                                   DB
                                         DB


                                   DB                                                    DB



                                                                     (3)Relay Log
                (1)           (INSERT,UPDATE   )
                                                                         SQL
                      Binary Log

                                                                       SQL
                                                    IO
                Binary Log
                                                                               Relay Log
                                                   (2)IO    Binary
                                                   Log
                                                       DB




2011   3   5
DB

       •        DB                  DB
           →MySQL         1


       •




           →                  SSD        cf.




2011   3   5
•
                           NG

       UPDATE history_tbl SET state = 2 WHERE state = 1 LIMIT 10

       →state=1



       UPDATE history_tbl SET state = 2 ORDER BY finish_time LIMIT 1

       →                  finish_time



       • UPDATE        WHERE      Primary Key




2011   3   5

Contenu connexe

Plus de Naoyuki Yamada

KubernetesでRedisを使うときの選択肢
KubernetesでRedisを使うときの選択肢KubernetesでRedisを使うときの選択肢
KubernetesでRedisを使うときの選択肢Naoyuki Yamada
 
いわき情報技術研究会20170513
いわき情報技術研究会20170513いわき情報技術研究会20170513
いわき情報技術研究会20170513Naoyuki Yamada
 
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみNaoyuki Yamada
 
東北Tech道場郡山20151031
東北Tech道場郡山20151031東北Tech道場郡山20151031
東北Tech道場郡山20151031Naoyuki Yamada
 
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介Naoyuki Yamada
 
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析Naoyuki Yamada
 
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social Graph
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social GraphCAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social Graph
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social GraphNaoyuki Yamada
 
Adtech College#7 GitHubを中心とした開発フロー
Adtech College#7 GitHubを中心とした開発フローAdtech College#7 GitHubを中心とした開発フロー
Adtech College#7 GitHubを中心とした開発フローNaoyuki Yamada
 
ElasticSearch勉強会 第6回
ElasticSearch勉強会 第6回ElasticSearch勉強会 第6回
ElasticSearch勉強会 第6回Naoyuki Yamada
 
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale Datasets
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale DatasetsCAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale Datasets
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale DatasetsNaoyuki Yamada
 
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへ
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへADTECH COLLEGE #2 近い将来、開発責任者になるあなたへ
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへNaoyuki Yamada
 
株式会社サイバーエージェント アドテクスタジオの技術と開発
株式会社サイバーエージェント アドテクスタジオの技術と開発株式会社サイバーエージェント アドテクスタジオの技術と開発
株式会社サイバーエージェント アドテクスタジオの技術と開発Naoyuki Yamada
 
Functional Programming in Scala Reading #2
Functional Programming in Scala Reading #2Functional Programming in Scala Reading #2
Functional Programming in Scala Reading #2Naoyuki Yamada
 
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまで
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまでCode for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまで
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまでNaoyuki Yamada
 
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作る
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作るJAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作る
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作るNaoyuki Yamada
 
データマイニング+WEB勉強会資料第6回
データマイニング+WEB勉強会資料第6回データマイニング+WEB勉強会資料第6回
データマイニング+WEB勉強会資料第6回Naoyuki Yamada
 
Social Web Japan Vol.3 "Social Application and their support services"
Social Web Japan Vol.3 "Social Application and their support services"Social Web Japan Vol.3 "Social Application and their support services"
Social Web Japan Vol.3 "Social Application and their support services"Naoyuki Yamada
 
ソーシャルアプリ業界を構成する中間サービスたち
ソーシャルアプリ業界を構成する中間サービスたちソーシャルアプリ業界を構成する中間サービスたち
ソーシャルアプリ業界を構成する中間サービスたちNaoyuki Yamada
 

Plus de Naoyuki Yamada (18)

KubernetesでRedisを使うときの選択肢
KubernetesでRedisを使うときの選択肢KubernetesでRedisを使うときの選択肢
KubernetesでRedisを使うときの選択肢
 
いわき情報技術研究会20170513
いわき情報技術研究会20170513いわき情報技術研究会20170513
いわき情報技術研究会20170513
 
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ
浪江町タブレットで採用した、 Cordovaで作るHTML5のAndroidアプリのしくみ
 
東北Tech道場郡山20151031
東北Tech道場郡山20151031東北Tech道場郡山20151031
東北Tech道場郡山20151031
 
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介
AWSからOpenStack, Chef SoloからChef Serverに インフラを置き換えた事例の紹介
 
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析
Elasticsearch勉強会第8回 ElasticsearchとKibanaで実現する 30億req/dayのリアルタイム分析
 
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social Graph
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social GraphCAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social Graph
CAジャーナルクラブ TAO: Facebook’s Distributed Data Store for the Social Graph
 
Adtech College#7 GitHubを中心とした開発フロー
Adtech College#7 GitHubを中心とした開発フローAdtech College#7 GitHubを中心とした開発フロー
Adtech College#7 GitHubを中心とした開発フロー
 
ElasticSearch勉強会 第6回
ElasticSearch勉強会 第6回ElasticSearch勉強会 第6回
ElasticSearch勉強会 第6回
 
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale Datasets
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale DatasetsCAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale Datasets
CAジャーナルクラブ Dremel: Interactive Analysis of Web-Scale Datasets
 
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへ
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへADTECH COLLEGE #2 近い将来、開発責任者になるあなたへ
ADTECH COLLEGE #2 近い将来、開発責任者になるあなたへ
 
株式会社サイバーエージェント アドテクスタジオの技術と開発
株式会社サイバーエージェント アドテクスタジオの技術と開発株式会社サイバーエージェント アドテクスタジオの技術と開発
株式会社サイバーエージェント アドテクスタジオの技術と開発
 
Functional Programming in Scala Reading #2
Functional Programming in Scala Reading #2Functional Programming in Scala Reading #2
Functional Programming in Scala Reading #2
 
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまで
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまでCode for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまで
Code for Japan 勉強会 Vol.1 CKAN入門 プロジェクトのFork、デプロイ、CIまで
 
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作る
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作るJAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作る
JAWS-2013-LT 10000req/secを50msecで返すサーバーインフラをAWSで作る
 
データマイニング+WEB勉強会資料第6回
データマイニング+WEB勉強会資料第6回データマイニング+WEB勉強会資料第6回
データマイニング+WEB勉強会資料第6回
 
Social Web Japan Vol.3 "Social Application and their support services"
Social Web Japan Vol.3 "Social Application and their support services"Social Web Japan Vol.3 "Social Application and their support services"
Social Web Japan Vol.3 "Social Application and their support services"
 
ソーシャルアプリ業界を構成する中間サービスたち
ソーシャルアプリ業界を構成する中間サービスたちソーシャルアプリ業界を構成する中間サービスたち
ソーシャルアプリ業界を構成する中間サービスたち
 

Dernier

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 

Dernier (20)

Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

社内勉強会:ソーシャルゲームのデータベース設計入門

  • 1. 2011 3 4 2011 3 5
  • 2. DB • Index Index Covering Index Primary Key Read Write • MySQL DB SQL 2011 3 5
  • 3. →(10001,A) ※ • Primary Key →Primary Key • Primary Key 2011 3 5
  • 4. ID ID 1 1 2 2 2 2011 3 5
  • 5. ID ID 1 10001 1 10002 2 10001 ID ID 1 10001 2 10002 1 10002 2 10001 2 10002 ID 10001 10002 2011 3 5
  • 6. ID ID 1 101 2 102 ID ID 3 103 1 101 4 102 2 102 3 103 4 102 ID 101 102 103 2011 3 5
  • 7. ALTER TABLE • • (ALTER TABLE) →ALTER TABLE • • → 2011 3 5
  • 8. ID ID 1 1 101 1 1 2 234 2 1 3 553 3 1 4 232 4 2 1 102 2 2 271 2 3 952 ID 1 101 234 553 232 873 0 102 0 2 102 271 8652 98 0 234 202 0 3 103 952 76 765 872 45 0 0 4 102 197 2312 762 4 232 672 34 • 2011 3 5
  • 9. Index • WHERE Index Primary Key WHERE user_id = 10001 → user_id Index( Primary Key) WHERE user_id = 10001 AND friend_id = 10002 → (user_id, friend_id) WHERE visiting_id = 10001 AND visited_id IN (1,2,3) AND action=2 → (visiting_id,visited_id,action) WHERE status = 2 ORDER BY start_time → (status,start_time) 2011 3 5
  • 10. Index • Index WHERE start_time < 12345678 AND state = 2 →(start_time,state) (state,start_time) • Index WHERE visited_id = 10002 AND visiting_id = 10001 AND action=2 → (visiting_id,visited_id,action) • Index WHERE visiting_id = 10001 AND action = 2 AND visited_id = 10002 → (visiting_id,visited_id,action) Index visiting_id 2011 3 5
  • 11. Covering Index • MySQL Covering Index - ( ∀ )o sasata299's blog http://blog.livedoor.jp/sasata299/archives/51336006.html • Covering Index → 2011 3 5
  • 12. Primary Key id • Primary Key → Primary Key MySQL id Primary Key MySQL :: MySQL 5.1 :: 13.5.13 InnoDB http://dev.mysql.com/doc/refman/5.1/ja/innodb-table-and-index.html • id WHERE id IN (a,b,c,d...) • id id Primary Key ( Covering Index ) 2011 3 5
  • 13. Primary Key • id Primary Key 1 Primary Key • id • id Primary Key (“WHERE user_id=10001” ) 2011 3 5
  • 14. auto_increment • ID CREATE TABLE seq_history( seq_id bigint unsigned not null ); • auto_increment MySQL5.1 DB auto_increment 2011 3 5
  • 15. Read Write • Read(SELECT) DB Write DB DB • Write SELECT • SELECT • Read Write 2011 3 5
  • 16. Read/Write SQL • IO → → 2011 3 5
  • 17. MySQL • DB DB DB DB DB (3)Relay Log (1) (INSERT,UPDATE ) SQL Binary Log SQL IO Binary Log Relay Log (2)IO Binary Log DB 2011 3 5
  • 18. DB • DB DB →MySQL 1 • → SSD cf. 2011 3 5
  • 19. NG UPDATE history_tbl SET state = 2 WHERE state = 1 LIMIT 10 →state=1 UPDATE history_tbl SET state = 2 ORDER BY finish_time LIMIT 1 → finish_time • UPDATE WHERE Primary Key 2011 3 5