Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
RDB(ぽすぐれ)チューニング入門/rdb-tuning-introduction-for-p...
Search
aono
October 09, 2024
Programming
200
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
RDB(ぽすぐれ)チューニング入門/rdb-tuning-introduction-for-postgresql
aono
October 09, 2024
More Decks by aono
See All by aono
Dockerfileチョットカケルになろう/dockerfile-next-steps
awonosuke
0
80
Other Decks in Programming
See All in Programming
JRuby: Past, Present, and Future
headius
0
170
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3k
一人だけ、Kiroが静止する日
hideg
0
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
260
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
5
3.2k
Jetpack Compose メカニズム
skydoves
0
450
技術的負債を組織課題として解く-増えすぎたマイクロサービスとの戦い-
reimaru
1
2.2k
FreeBSDでZabbixを動かす
kenkino
0
310
XP祭りでしか伝わらないフリップネタ #xpjug
murabayashi
0
150
Intent as Code
shoppingjaws
6
1.1k
AI × TiDD / 2026.09.05 Redmine 大阪
tokudiro
1
180
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
2.4k
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
22k
Being A Developer After 40
akosma
91
590k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
410
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
830
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8.3k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
530
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Making Projects Easy
brettharned
120
6.8k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
420
Transcript
RDB(ぽすぐれ)チューニング入門
目次 1. RDBチューニング_戦略編 2. RDBチューニング_戦術編 3. まとめ 4. 補足
RDBチューニング_戦略編 • 早めに削る • 効率的に削る • チートで削る
RDBチューニング_戦略編 • ep. 0: 遅いクエリはEXPLAINで実行計画を見る ◦ 遅い原因を特定してから適切な対応をする ◦ そもそも遅いクエリを検知できないといけない→スロークエリの監視をする •
早めに削る • 効率的に削る • チートで削る
RDBチューニング_戦術編 • 早めに削る ◦ テーブルを小さくする ▪ テーブル分割 • パーティション(RANGE・LIST・HASH) •
シャーディング ◦ SQLの評価順を意識して削る(細かいとこは割愛) ▪ FROM→サブクエリとかとか ▪ ON, JOIN ▪ WHERE ▪ GROUP BY ▪ HAVING ▪ SELECT ▪ DISTINCT ▪ ORDER BY ▪ LIMIT
RDBチューニング_戦術編 • 早めに削る • 効率的に削る ◦ joinしない→サマリテーブル(=非正規化) ◦ 不要データを削ぐ ▪
ON句、WHERE句 ▪ SELECT句でカラム選択 ◦ パーティショニング ◦ ページネーション • チートで削る
RDBチューニング_戦術編 • 早めに削る • 効率的に削る • チートで削る ◦ クエリ呼び出しを減らす ▪
アプリケーション側での制御 ◦ indexを張る ▪ 複合indexのカラム順番大事→ユースケースを意識(参考) • CREATE INDEX hoge_index ON fuga USING btree (c3, c1, c2 DESC) ▪ カバリングインデックス ◦ RDBMSのパラメータチューニング(参考:DBサーバのスペックで推奨値を算出) ▪ shared_buffers、work_mem、effective_cache_sizeとかがパフォーマンス直結 ◦ お金で解決(💸👋) ▪ DBサーバのスペック上げる ▪ リードレプリカを増やす ◦ RDBを利用しない ▪ NoSQL ▪ NewSQL(SQLがインターフェース)
まとめ • 戦略を立てるの大事 ◦ 初手index張って改善しようとしてあまりうまく行かなかった ▪ 敵を知って戦う準備を整える • 調査と泥臭い検証 ◦
実行計画見よう ◦ 何か試す→実行計画見よう ▪ データ量によっても実行計画が変わる→統計情報を定期的にアップデート
補足 • 機械学習を利用したパラメータチューニングとかもあるらしい ◦ https://pgecons-sec-tech.github.io/tech-report/html_wg3_ml_tuning/wg3_ml_tun ing.html
参考 • PostgreSQL 日本語ドキュメント • [富士通] PostgreSQL技術インデックス • 複合indexの正しい順序 •
Where狙いのキー、order by狙いのキー • PostgreSQLの実行計画を読み解くための参考資料集