7. Key Points
Programming language can
break large part into small pieces
construct large part from small pieces
add name to pieces in order to abstract
them
8. Again, What is the Problem?
• SQL can't break large one into pieces
• SQL can't be constructed from pieces
• SQL can't name or abstract pieces
11. History of Evolution
OOP,
Modern ORM
Functional
C, Pascal DBI, ORM
Assembler SQL
12. Conclusion of this section
SQL is just Assembler
It can't be broken into pieces
It can't be constructed from pieces
It can't name or abstract pieces
Modern ORM provides abstraction for
SQL
ex. named_scope
39. Sol: Lazy Loading
Pros.
Caching on V doesn't affect to C
Cons.
Availables only on modern ORM
(not available on Rails2)
40. Conclusion of this section
MVC and fragment cache are not good
friends
MVC: push-style
Fragment cache: pull-style
Laziness solves them
Proc or lambda
Lazy loading
47. Sol: Strategic Eager Loading
• Each item knows its collection
• Collection resolves relationships
48. Sol: Strategic Eager Loading
Pros.
Adaptive to changes
(No need to specify relationship for eager
loading)
Cons.
Not supported in Rails (2 & 3)
49. Conclusion of this section
Eager loading
Easy to forget, hard to notice
Strategic Eager Loading
No need to specify relation names
Adaptive to changes