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
Ambiguous Groups #sqlap
Search
grimrose
February 05, 2014
Programming
950
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Ambiguous Groups #sqlap
SQLアンチパターン読書会 「アンビギュアスグループ」
grimrose
February 05, 2014
More Decks by grimrose
See All by grimrose
だいたい10分くらいで 知った気になれる Vert.x 3.0 #渋谷Java / Shibuya.java #11
grimrose
0
1.9k
Syobochim should read book of modeling #syoboben
grimrose
0
1.9k
Gradleで始めるGroovy expand #jjug_ccc #ccc_r14
grimrose
4
6.2k
I wanna tell you about "Groovy Template"
grimrose
3
5.5k
Groovy Shell with Gradle
grimrose
0
5.3k
Shibuya.Java #07
grimrose
0
900
ぼっちプロジェクトとアジャイルサムライ
grimrose
0
310
Shibuya.Java #04
grimrose
1
680
I made out Gradle plug-in
grimrose
0
970
Other Decks in Programming
See All in Programming
ハーネス設計入門 〜 基礎知識の整理から実務へのステップアップ 〜
kinopeee
25
28k
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
600
カツオ、ご期待ください
suneo3476
0
180
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
430
ジョジョの世界をXRで再現する
mofurune
0
160
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
APNsからLive Activityを開始する話
yumnumm
0
170
AI主導のプログラミング学習アプリを作ってみた
econanringo
0
180
残高管理から台帳サービスへの進化
artoy
1
200
Railsバージョンを4倍にした話
optim
0
290
Jetpack Compose Mechanisms
skydoves
3
800
最近”作らせてる” ローカルAIアプリの話
akit37
0
470
Featured
See All Featured
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
520
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
Building an army of robots
kneath
307
47k
Building Adaptive Systems
keathley
44
3.2k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
550
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Utilizing Notion as your number one productivity tool
mfonobong
4
620
Tell your own story through comics
letsgokoyo
1
1.1k
Darren the Foodie - Storyboard
khoart
PRO
4
4k
Git: the NoSQL Database
bkeepers
PRO
433
67k
Transcript
SQLアンチパターン読書会 14章 「アンビギュアスグループ」 2014/02/06 @grimrose
目的 グループ内で最大値を持つ行
アンチパターン 非グループ化列を参照する
単一値の原則 Single-Value Rule
アンチパターンの見つけ方 _人人人人人人人人人人_ > エラーメッセージ <  ̄Y^Y^Y^Y^Y^Y^Y^Y^Y ̄ ※SQLiteとMySQLを除く
アンチパターンを用いてもよい場合 MySQLとSQLiteの場合 関係従属性を持つ列のみに クエリを実行するように注意
解決策 曖昧でない列を使用する
関数従属性のある列のみ クエリから曖昧な列を排除
相関サブクエリ • 読みやすい • コードの記述も簡単 • パフォーマンスに注意
導出テーブル • 相関サブクエリよりパフォーマ ンスが高い • テンポラリテーブル
JOIN • 大量のデータに対するパフォーマンス が重要な場合 • パフォーマンスの測定してね
他の列に対しても集約関数 単一値の原則
グループ毎に全ての値を連結 • GROUP_CONCAT関数 ◦ MySQL, SQLite • PostgreSQLの場合 ◦ ARRAY_TO_STRING(ARRAY_AGG(any),
',') • カスタム関数 • ストアドプロシージャ
まとめ 曖昧なクエリ結果を避けるために、 単一値の原則に従う