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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
forcia_dev_pr
February 21, 2022
Programming
590
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
More Decks by forcia_dev_pr
See All by forcia_dev_pr
"書く文化"を仕組みで育てる──フォルシアの技術ブログ継続戦略
forcia_dev_pr
1
300
新しいおもちゃを見つけたい私がやっている情報収集
forcia_dev_pr
2
500
「Pythonの環境構築について」と記事作成で意識したこと
forcia_dev_pr
1
210
Neovim で VS Code みたいにコーディングする
forcia_dev_pr
1
240
なぜ・どうやって・何を書く? 〜技術記事を書く習慣の作り方〜
forcia_dev_pr
1
240
第8回ゆるふわオンサイト 解説スライド
forcia_dev_pr
0
240
第7回ゆるふわオンサイト解説
forcia_dev_pr
0
320
第6回ゆるふわオンサイト解説
forcia_dev_pr
0
320
よくわかるFORCIAのエンジニア旅行SaaSプロダクト開発編
forcia_dev_pr
0
1.4k
Other Decks in Programming
See All in Programming
JIS keyboard support in Omarchy
lef237
0
110
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
140
全ての永続トークンを、生まれる前に消し去りたい!
sylph01
2
890
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
[Dev Group Paris Octobre 26] Agentforce, SIforce, Claudeforce, Slackbot… on s'y retrouve ?
nabondance
0
110
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
0
1.2k
複雑なUIコンポーネントとの ⻑い付き合い⽅:波及するバグからテスト戦略を経て、安全な再設計へ
mixplace
0
410
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
290
AIに “答え“を書かせるのを やめてみた
___akari11
0
120
Kotlinの15年とServer-Side Kotlin
n_takehata
1
150
S3 TablesのIcebergデータに、AIエージェントからアクセスしてみた / 20261016developersio2026joetsu-accessing-iceberg-in-s3tables-via-agent
kasacchiful
PRO
0
150
Featured
See All Featured
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
460
Building Adaptive Systems
keathley
44
3.2k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3.1k
Leveraging LLMs for student feedback in introductory data science courses - posit::conf(2025)
minecr
1
440
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Ruling the World: When Life Gets Gamed
codingconduct
0
400
Future Trends and Review - Lecture 12 - Web Technologies (1019888BNR)
signer
PRO
0
3.8k
Producing Creativity
orderedlist
PRO
348
41k
Building an army of robots
kneath
307
47k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
460
What's in a price? How to price your products and services
michaelherold
247
13k
Speed Design
sergeychernyshev
33
2.2k
Transcript
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