I like to understand Doctrine more and want to analyze the SQL which doctrine builds out of my DQL or the find method.
Is it possible to print the statement out in PHP?
Another question is: Is it more performant, to write own DQLs especially with some joins or is doctrine smart enough to match these when I use the find method?
According to Logging Doctrine SQL queries in Symfony2:
You can use a Doctrine logger such as DebugStack or own implementation of SQLLogger interface.
$logger = new \Doctrine\DBAL\Logging\DebugStack();
/* @var Doctrine\DBAL\Connection $connection */
$connection->getConfiguration()->setSQLLogger($logger);
After execution of some queries you can get query strings and parameters from public property of the logger.
var_dump($logger->queries);
You second question is very different. Btw, as said in documentation:
Objects that were not already loaded from the database are replaced with lazy load proxy instances. Non-loaded Collections are also replaced by lazy-load instances that fetch all the contained objects upon first access. However relying on the lazy-load mechanism leads to many small queries executed against the database, which can significantly affect the performance of your application. Fetch Joins are the solution to hydrate most or all of the entities that you need in a single SELECT query.