Ruby on Rails Wednesday, March 28, 2018

As I'm going through my project I'm looking at places in my application that are causing pages to load longer than perhaps they should.  I'm finding some queries that execute for my page navigation that happen each time a page reloads, but their information that is returned doesn't usually change.  An example I have would be I display 32 NFL Club logos that serve as links to each clubs page in my navigation.  The query looks like this:

SELECT [clubs].* FROM [clubs] WHERE (clubs.is_disabled = 0)  ORDER BY [clubs].[city] ASC;


Now this code runs in development and it's saying it takes 32.9ms to execute.  But to my point these 32 clubs rarely change.  Is there a different approach I should be taking to this other than having it run on every page request? Thanks!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/28bf3cfa-33d1-4c90-b1fe-201ae727045d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment