[Ruby] Show SQL for Active Record

Ryan Davis ryand-ruby at zenspider.com
Mon Jan 29 17:40:54 PST 2007


On Jan 29, 2007, at 5:29 PM, Neil Moomey wrote:

> Is there a trick for showing the sql Active Record generates?  I've  
> been
> misspelling a fieldname on purpose to generate an error so it will  
> display
> the sql but there must be a better way.  Sometimes it's nice to see  
> the SQL
> especially for creating indexes.

I just look at the logs. I have some simple scripts to strip off the  
log header, convert UUIDs and timestamps to stupid tokens, and then I  
can use my occur script to aggregate the log and see what actually  
needs indexing. In the same way that programmers are horrid at  
guessing where bottlenecks are, you should always measure instead of  
guess.



More information about the Ruby mailing list