views:

43

answers:

1

I'm trying to figure out where a whole pile of extra queries are being generated by my rails app. I need some ideas on how to tackle it. Or, if someone can give me some hints, I'd be grateful.

I get these:

  SQL (1.0ms)    SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'

  SQL (0.8ms)    SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'

  SQL (0.8ms)    SELECT name
 FROM sqlite_master
 WHERE type = 'table' AND NOT name = 'sqlite_sequence'

repeated over and over on every request to the DB (as much as 70 times for a single request)

I tried installing a plugin that traced the source of the queries, but it really didn't help at all. I'm using the hobofields gem, dunno if that is what's doing it but I'm somewhat wedded to it at the moment

Any tips on hunting down the source of these extra queries?

A: 

It's very difficult to tell this without look into the Code.

but i am sure you write your query in a certain loop

for i in 0..70
  SqliteMaster.find(:all, :conditions=>["type=? and not name=?", 'table', 'sqlite_sequesnce'])
end

So my advice is that to check all the methods which gets called after requesting certain method and look whether the query called in a loop.

Salil