Created
September 14, 2012 11:22
-
-
Save tell-k/3721387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# relationship('Comment', lazy="subquery") | |
# ------------------------------------------ | |
# * 取得タイミング | |
# * Entryを取得後、EntryのId列だけを取得して、そのId列のCommentのみを取得 | |
# | |
# entry = Entry.query.filter_by(id=1).first() <- タイミングここ | |
# entry.comments | |
# | |
# * 発行SQL | |
# 1. SELECT * FROM entries WHERE entries.id = 1 LIMIT 1 | |
# 2. SELECT comments.*, anon_1.entries_id | |
# FROM ( | |
# SELECT entries.id AS entries_id | |
# FROM entries | |
# WHERE entries.id = 1 LIMIT 1 | |
# ) AS anon_1 | |
# INNER JOIN comments | |
# ON anon_1.entries_id = comments.entry_id | |
# ORDER BY anon_1.entries_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment