Wednesday, October 24, 2007

Grails Tip: Enable SQL Logging

Here is a great tip while developing a Grails application to enable SQL logging (I would only recommend this in development mode).
In your grails project add the loggingSql = true property to the development closure and that is it. This was using Grails 1.0-RC1.

development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop','update'
url = "jdbc:hsqldb:mem:devDB"
loggingSql = true
}
}

Then after starting your app (grails run-app) the SQL will be displayed. I was actually surprised for some reason when the list action was doing a specific select statement like "select title, author from book" rather than "select * from book".

2 comments:

Deigote said...

I guess it's faster to retrieve some given columns than all of them (with the *), since in the second case first you have to read what columns has the table you are consulting :-).

Anonymous said...

cheers men its work out