John Merlino
2013-Mar-15  16:20 UTC
check how long individual active record queries take to the database
I know that Rails output log shows how many milliseconds a sql query
take but I''m looking for something more fine-tuned. I want to know how
long individual activerecord queries take on an indiivdual basis. For
example, I have code that looks like this:
        items = current_user.accessible_items
        @items = items.where{item_id =my{current_user.item_id}}.ordered
        @other_items = current_user.accessible_items.where{item_id
!my{current_user.item_id}}.ordered
        @accounts = @other_items.accounts.ordered
There are several database hits here. How can I check how long they
take?
-- 
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Dmitry Maksyoma
2013-Mar-16  11:19 UTC
Re: check how long individual active record queries take to the database
On Saturday, March 16, 2013 5:20:05 AM UTC+13, John Merlino wrote:> > I know that Rails output log shows how many milliseconds a sql query > take but I''m looking for something more fine-tuned. I want to know how > long individual activerecord queries take on an indiivdual basis. For > example, I have code that looks like this: > > items = current_user.accessible_items > @items = items.where{item_id == > my{current_user.item_id}}.ordered > @other_items = current_user.accessible_items.where{item_id != > my{current_user.item_id}}.ordered > @accounts = @other_items.accounts.ordered > > There are several database hits here. How can I check how long they > take? > >If you''re using Postgres, you can turn on query times for it. It may be queries longer than N ms or something. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/6tsrTi8qLk8J. For more options, visit https://groups.google.com/groups/opt_out.