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
PostgreSQL開発とテスト
Search
forcia_dev_pr
February 21, 2022
Programming
600
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
PostgreSQL開発とテスト
「FORCIA Meetup #4 高速検索を支えるPostgreSQLのノウハウ」の資料です
forcia_dev_pr
February 21, 2022
Transcript
14 slides
PostgreSQL開発とテスト 吉田 侑弥 @フォルシア株式会社 2022.02.15 FORCIA Meetup#4
自己紹介 • 吉田 侑弥 (Yuya Yoshida) • ソフトウェアエンジニア@フォルシア株式会社 ◦ webアプリケーション
(TypeScript, Node.js, React, Next.js, NestJS, PostgreSQL) ◦ 大規模アプリ開発 ◦ パフォーマンスチューニング 2
DB関連のテストは(比較的)大変 • 一般的には ◦ アプリと比較して環境構築のコストが高い ◦ 作業者間の差異がない環境下のテスト(再現性の担保)が難しい • フォルシアでは以下のような工程が多い ◦
元のデータを検索用データに加工する(バッチSQL) ◦ データから必要なデータを高速に抽出する(オンラインSQL) ◦ 汎用的なモジュール開発(拡張機能やユーザー定義関数) →比較的テストの実施が容易な環境 3
テスト観点① • バッチSQL ◦ バッチ処理が正常終了するか ◦ 処理が意図した通りか • オンラインSQL ◦
正しいSQL文が生成されるか ◦ クエリが意図した通りか 4
テスト観点①…実施パターン • バッチSQL ◦ バッチ処理が正常終了するか → テストデータでバッチ実行 ◦ 処理が意図した通りか →
結合テスト • オンラインSQL ◦ 正しいSQL文が生成されるか → スナップショットテスト ◦ クエリが意図した通りか → 結合テスト 5
6 (補足)JSのテスト環境(Jest + Frisby) 6 • Jest: JSのテストフレームワーク • Frisby:
Jest上で動くAPIテスト フレームワーク • SQL文の生成はJest単体、結合テス トはJest + Frisbyで実施
拡張機能とは • postgreSQLは拡張性の高いRDBMS • フォルシアでも多くの拡張機能を活用 • 外部ツール ◦ pg_bigm, pg_bulkload
etc… • 自社ツール ◦ ユーザー定義関数(C言語) etc… 7
テスト観点② • 拡張機能・ユーザー定義関数 ◦ 正しく導入できるか ◦ 意図した結果を得られるか 8
テスト観点②…実施パターン • 拡張機能・ユーザー定義関数 ◦ 正しく導入できるか →仮想環境 (docker) でのビルド、インストール ◦ 意図した結果を得られるか
→リグレッションテスト 9
仮想環境 (docker) でのビルド • 新規プロジェクトの多くは仮想環境でDBサーバーを用意 →社内共通のpostgreSQLイメージを利用 • 汎用モジュール開発時 ◦ 共通イメージ環境下でのビルド、テスト(推奨)
10
pg_regress • postgreSQL標準のリグレッションテストツール • 実行すると一時的にサーバーが起動し、テスト用のDBが生成される • 予めSQL文と実行結果の準備が必要 11
DBテストとCI • これまで挙げたテストは全て手元だけでなくCIでも実行 ◦ DB周りの処理はどうしても環境の差異が出やすい CIでエラー検知するケースは体感かなり多い • ただし、ある程度マシンパワーと時間が必要 →時には実行タイミングをある程度制御することも e.g.
ビルドはmaster merge時のみ、バッチ処理は定時実行 等々… 12
現在議論中の内容 • SQLのsyntax check ◦ DBサーバーを介さずにチェックができると嬉しい ◦ pglast等を活用して実現できそう? • パフォーマンステスト
◦ 拡張や関数の効果を定量的に測定したい ◦ 実現方法を模索中 13
EOF
More Decks by forcia_dev_pr
See All by forcia_dev_pr
第9回ゆるふわオンサイト_解説スライド.pdf
forcia_dev_pr
0
93
"書く文化"を仕組みで育てる──フォルシアの技術ブログ継続戦略
forcia_dev_pr
1
320
新しいおもちゃを見つけたい私がやっている情報収集
forcia_dev_pr
2
510
「Pythonの環境構築について」と記事作成で意識したこと
forcia_dev_pr
1
210
Neovim で VS Code みたいにコーディングする
forcia_dev_pr
1
250
なぜ・どうやって・何を書く? 〜技術記事を書く習慣の作り方〜
forcia_dev_pr
1
250
第8回ゆるふわオンサイト 解説スライド
forcia_dev_pr
0
300
第7回ゆるふわオンサイト解説
forcia_dev_pr
0
330
第6回ゆるふわオンサイト解説
forcia_dev_pr
0
330
Other Decks in Programming
See All in Programming
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
190
Web Framework Benchmark Battle 2026, Any%
a_matsuda
3
3.2k
Seven New Principles of Software Engineering
yegor256
0
490
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
380
小さなアプリを作って公開するまで
onozaty
0
170
Modernizing iOS Apps
seyfoyun
0
150
Railsバージョンを4倍にした話
optim
0
1k
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
5.7k
Railsのためのパスキー実践入門 〜マルチテナントSaaSでの意思決定〜
utakaha
4
4.3k
[Kotlin Fest 2026] eBPF Tracing for Kotlin
takehaya
0
120
SODA - FACT BOOK(EN)
sodainc
1
240
AI-Powered Domain-Driven Design
ziobrando
0
440
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
96
6.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
760
Testing 201, or: Great Expectations
jmmastey
46
8.4k
Optimising Largest Contentful Paint
csswizardry
37
4k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
990
Effective software design: The role of men in debugging patriarchy in IT @ Voxxed Days AMS
baasie
1
610
Prompt Engineering for Job Search
mfonobong
0
580
Paper Plane (Part 1)
katiecoart
PRO
3
12k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
560
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The agentic SEO stack - context over prompts
schlessera
0
1k
The SEO identity crisis: Don't let AI make you average
varn
0
630