Is it possible to review/optimize a Hibernate query plan?
Is there some facility in Hibernate for viewing the query plan for a query? I can look at the source code and trace the joins and eager fetches and hope that I don't miss any, or I can look at the SQL log and try to match up a SQL statement with its source, but I was wondering if there was a faster way. e.g., I can imagine an object diagram showing the relevant classes or an E-R diagram with some kind of s开发者_运维问答equencing notation.
Many times the underlying database engine will show you the plan. If you have the SQL queries being produced by Hibernate, you can prepend it with EXPLAIN
EXPLAIN SELECT blah blah blah
I'm using MySql on Linux so I can get this output without having to go through the Hibernate SQL output - I run mytop and hit 'e' when I see the query I'm interested in. I expect most database servers offer similar diagnostics.
精彩评论