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
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
230
第7回ゆるふわオンサイト解説
forcia_dev_pr
0
310
第6回ゆるふわオンサイト解説
forcia_dev_pr
0
310
よくわかるFORCIAのエンジニア旅行SaaSプロダクト開発編
forcia_dev_pr
0
1.4k
Other Decks in Programming
See All in Programming
AIを上手に使っていこうとしたら越境せざるを得なくなった話 〜実践1年で見えた境界を越えなければならない理由と進め方〜 / Crossing borders with AI
tomoyakitaura
4
1.1k
『寄り添うラジオ』をAIで作る 体験価値から逆算した、会話しないUXと品質設計
theoriatec2024
3
150
変化を抱擁するドキュメントの作り方 - ビジネスルール駆動開発がもたらす、コードとの新しい関係
ioki
2
150
[GoCon2026] When Goroutines Are Not Enough: Runtime Locality in High-Throughput Go
takehaya
6
2k
ゲームコントローラやキーボードのファームウェアをSwiftで書く
kishikawakatsumi
1
220
高専キャリア LT 発表内容
crysta1221
6
5.7k
Security issues being discussed on Web Platforms
petamoriken
0
780
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
520
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
RSSとCodexを使ってX投稿自動化してみた
ochtum
0
110
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
100
Swift愛好会と私(ウホーイ) / Swift Fan Club and Uhooi
uhooi
0
150
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
500
Design in an AI World
tapps
1
310
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.3k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
450
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
2
500
Building Applications with DynamoDB
mza
96
7.2k
Winning Ecommerce Organic Search in an AI Era - #searchnstuff2025
aleyda
1
2.1k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
1
270
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
240
New Earth Scene 8
popppiees
3
2.6k
SEOcharity - Dark patterns in SEO and UX: How to avoid them and build a more ethical web
sarafernandez
0
270
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