The document discusses debugging Grails database performance issues. It notes that while GORM provides easy data access from anywhere in a Grails application, this can lead to unclear data access patterns and unintended queries. It then introduces the MVC Mini Profiler tool for tracking database queries and tying them to specific parts of the codebase. The document demonstrates this tool and outlines plans to implement more of its features for Grails and support non-SQL stores.
2. Tom Dunstan / @tomdcc
tom@energizedwork.com
#ggx
LICENSEDUNDERCREATIVECOMMONSBYENERGIZEDWORKLIMITED |HMSPRESIDENT,VICTORIAEMBANKMENT,LONDON,EC40HJ|WWW.ENERGIZEDWORK.COM 2
3. ✪ GORM
• One of the best parts of Grails
• Easy data access
• No DAOs etc required
• Can access data from anywhere
4. ✪ GORM
• Can access data from anywhere
• This can be dangerous
• Many data access patterns can coexist
• Difficult to work out what is generating a
particular query
5. ✪ GORM
• Getting data out of collections can have
unintended consequences
6. ✪ WHERE CAN WE ACCESS DATA?
• Filters
• URL Mapping Constraints
• Controllers
• Services
• Modules
• Named Queries
• Helper classes
• Views
• Tag Libraries
7. ✪ WHERE CAN WE ACCESS DATA?
• It may not be apparent exactly when
data is being fetched
8. ✪ SPAGHETTI
• Long lived projects can evolve
multiple ways of doing things
10. ✪ SORTING IT OUT
• Logging SQL doesn’t tie generated SQL to
specific parts of the codebase
11. ✪ SORTING IT OUT
• Existing profiler plugin can automatically log
controller, service and view entry / exits
• Not bad, but doesn’t tie SQL queries to those
places
• Stuff in e.g. taglibs isn’t made explicit
• Stuff in layout vs main view isn’t made explicit
12. ✪ THE TARGET
• MVC Mini Profiler
• Developed for Stack Overflow
• Keeps performance on your mind
15. ✪ CURRENT STATUS
• Version 0.1
• Just pushed to Github
• Plugin waiting for approval
• Not all features of MVC Mini Profiler
16. ✪ FUTURE
• Implement missing MVC Mini Profiler features
– SQL Storage
– Detect Duplicate SQL queries
17. ✪ FUTURE
• Grails profiler plugin needs some work for 2.0+
• Not tested on 2.0+
18. ✪ FUTURE
• Split out separate Java library to share
functionality with other frameworks
• Show nested GSP names
• Show Tag Library calls
• EXPLAIN functionality built in
– Debug query performance from within app
– Supported by PostgreSQL, MySQL, others?
• Support non-SQL data stores