#836 ✓resolved
Arnaud D.

hundreds of queries show_tables

Reported by Arnaud D. | October 25th, 2010 @ 10:33 PM | in Hobo 1.3 (Rails 3)

Hi,

I don't remind to have this issue with previous version I tested (hobo pre9), but now, with pre13, I have a hundreds of queries done to the database in any of my actions: "show tables".

I have seen that tickets exist about that and those were explained by function table_exist? used too much time.

This is quite annoying since it slows down hobo in an impressive way (till 3 times slower than hobo 1.0.1 in development mode)

If you need an further tests or logs, don't hesitate to ask.
Regards.

Comments and changes to this ticket

  • Domizio Demichelis

    Domizio Demichelis October 26th, 2010 @ 02:54 AM

    • State changed from “new” to “investigating”
    • Milestone set to Hobo 1.3 (Rails 3)
    • Assigned user set to “Domizio Demichelis”
    • Milestone order changed from “197912” to “0”

    Yes, that's annoying.

    I have a patch that seems to work, but I am a little reluctant to apply it because it cache the table_exists? result in the model itself while IMO it should be cached at the adapter level.

    Here is the patch:

    diff --git a/hobo/lib/hobo/model.rb b/hobo/lib/hobo/model.rb
    index a66e347..a0a0466 100644
    --- a/hobo/lib/hobo/model.rb
    +++ b/hobo/lib/hobo/model.rb
    @@ -333,6 +333,11 @@ module Hobo
             class_name.safe_constantize or Object.class_eval("class #{class_name} < Hobo::ViewHints; end; #{class_name}")
           end
     
    +      def table_exists?
    +        @table_exists_cache = super if @table_exists_cache.nil?
    +        @table_exists_cache
    +      end
    +
     
         end # --- of ClassMethods --- #
    
  • Domizio Demichelis

    Domizio Demichelis October 27th, 2010 @ 10:18 PM

    • State changed from “investigating” to “resolved”

    (from [8eb0547d2ca3df3cdc127c5e437c84a4ea6ebf52]) fix for the too many query generated by too many table_exists? calls [#836 state:resolved] http://github.com/tablatom/hobo/commit/8eb0547d2ca3df3cdc127c5e437c...

  • Domizio Demichelis

    Domizio Demichelis December 4th, 2010 @ 10:09 AM

    The number of that kind of queries per request depends from the number of models in your application. In developer mode we need to check and cache at least one time for each model, so from your log I would say that your application has probably around 10 AR models. Is that correct?

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

People watching this ticket

Referenced by

Pages