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
Transcript
14 slides
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),
',') • カスタム関数 • ストアドプロシージャ
まとめ 曖昧なクエリ結果を避けるために、 単一値の原則に従う
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
910
ぼっちプロジェクトとアジャイルサムライ
grimrose
0
310
Shibuya.Java #04
grimrose
1
690
I made out Gradle plug-in
grimrose
0
980
Other Decks in Programming
See All in Programming
React Native経験者が Flutterを30⽇間触って驚いたこと
3saito
0
190
SFCで実現する病院・医療システムの動的組み立て式UI
koukimiura
1
180
Scalaの型でマルチテナントの認可を守る
nextbeatdev
0
130
protojson における文字化けの扱い
kazuki1023
0
430
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
9.2k
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
310
Claude Code ハーネスDeep Dive – 君はどこまで制御する? -
takateeen_knj
6
5.8k
動画プレイヤーはなぜカクつくのか 〜Flutterのレンダリングとネイティブの境界を解剖する〜
naruogram
0
340
우리의 Nitro Modules는 당신의 Turbo Modules보다 아름답다
l2hyunwoo
0
260
Materialが消えた日 〜真っ白なFlutterキャンバスにRenderObjectで絵を描く〜
umigishiaoi
0
160
AIで開発が速くなった先で、開発チームは何を目指すか
shihochan
1
2.1k
AI駆動開発4年目の現在地(『あなたはFDEになるべきか?』イベント資料)
kumaiu
0
620
Featured
See All Featured
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
18k
Side Projects
sachag
456
43k
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
470
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.6k
Accessibility Awareness
sabderemane
1
300
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
560
Joys of Absence: A Defence of Solitary Play
codingconduct
1
580
The SEO identity crisis: Don't let AI make you average
varn
0
630
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
121
130k
Writing Fast Ruby
sferik
630
63k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
770