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
Django QuerySet "ARE" Patterns
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
HayaoSuzuki
May 18, 2019
Technology
3.4k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Django QuerySet "ARE" Patterns
DjangoCongress JP 2019 Lightning Talk
HayaoSuzuki
May 18, 2019
More Decks by HayaoSuzuki
See All by HayaoSuzuki
Let's implement useless Python objects (revised)
hayaosuzuki
0
68
Tomorrow graphlib, Let us use everybody
hayaosuzuki
1
2.5k
Tasting "Python Distilled"
hayaosuzuki
0
420
Let's implement useless Python objects
hayaosuzuki
0
2.1k
How to Write Robust Python Code
hayaosuzuki
5
4.8k
Unknown Evolution of the Built-in Function pow
hayaosuzuki
0
1.5k
Python for Everyday
hayaosuzuki
1
2.5k
How to Use In-Memory Streams
hayaosuzuki
1
6.6k
Do you know cmath module?
hayaosuzuki
0
3.4k
Other Decks in Technology
See All in Technology
仕様駆動開発の、その先へ。決める力と確かめる仕組み
inariku
1
150
キヨさん、67歳。AIコーディングエージェントに挑む
happysamurai294
0
130
AIエージェントに 権限と鍵をどこまで渡すか
nrinetcom
PRO
2
160
200人の配信コメント、 全部Jevが仕分けます 〜 マサカリガードを作ってみた 〜
katayamatg
1
470
20261031_IoTLT_vol140_kitazaki_v1.pdf
kitazaki
0
130
スマートロックを支えるFlutter × ネイティブ連携の実践 / Flutter and Native Integration in Practice: Powering Smart Locks
bitkey
PRO
0
120
なぜAI時代に技術記事を書くのか?どう書くのか? 〜bunの場合〜
kworkdev
PRO
0
1.3k
アクセラレーターで実現するServiceNow活用の高速化 / ServiceNow World Forum 2026
visional_engineering_and_design
0
110
書き手が人でもAIでも正しくなる道、SREを埋め込んだDeveloper Platform / tech drivers day8
chmikata
4
860
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
110
[General] 개발자로 해외 기업에서 일하기
skydoves
1
160
AIエージェント統制はAPIから——押さえるべき5つの要素
nagix
0
110
Featured
See All Featured
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
500
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
590
Ruling the World: When Life Gets Gamed
codingconduct
0
430
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
440
HDC tutorial
michielstock
2
990
Testing 201, or: Great Expectations
jmmastey
46
8.4k
The Pragmatic Product Professional
lauravandoore
37
7.5k
The Mindset for Success: Future Career Progression
greggifford
PRO
0
550
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
750
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
2
970
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
370
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Transcript
明日から使うな! Django QuerySet アレパターン Hayao Suzuki @CardinalXaro
おまえ誰よ • Hayao Suzuki @CardinalXaro • 株式会社アイリッジ ◦ Pythonエンジニア ◦
テックリード(自称) • オライリージャパンの回し者 ◦ テクニカルレビュワー(自称)
今日のテーマ • Django QuerySetでやらかした思い出を語る。 • 本日、スマートフォンで作ったスライドなので手抜きです。 • この発表はフィクションであり、営業さんが客先で軟禁されたとか エンジニアが土日待機したなどの事実はありません。
indexを張らずにDBがスパイクした • token = models.TextField(max_length=200) • token = models.CharField(max_length=200, db_index=True)
年月日で調べたい 'regist_dt__year': today.year, 'regist_dt__month': today.month, 'regist_dt__day': today.day
なんだこれは、たまげたなあ WHERE (EXTRACT(DAY FROM `regist_dt`) = 28 AND EXTRACT(MONTH FROM
`regist_dt`) = 1 AND `regist_dt` BETWEEN '2019-01-01 00:00:00' AND '2019-12-31 23:59:59.999999'
こうした 'regist_dt__gte': datetime.datetime.combine(datetime.date.today(), datetime.time.min), 'regist_dt__lte': datetime.datetime.combine(datetime.date.today(), datetime.time.max),
そうそうこれだよ WHERE (`regist_dt` >= 2019-01-28 00:00:00 AND `regist_dt` <= 2019-01-28
23:59:59.999999
結論 • 実行計画調べよう • SQL見よう • LT資料は事前に準備しよう