Don.Mc
2007-Jun-10 14:09 UTC
Duplicate ''SHOW FIELDS'' statements when inserting data for production website
I am using a HABTM relationship for my app. When inserting data for a number of collection objects, I am seeing a ''SHOW FIELD'' query as each row is inserted: 0m [4;36;1melements_tags Columns (0.020000) [0m [0;1mSHOW FIELDS FROM elements_tags [0m [4;35;1mSQL (0.010000) [0m [0mINSERT INTO elements_tags (`element_id`, `tag_id`, `add_flag`) VALUES (3140, 2, NULL) [0m [4;36;1melements_items Columns (0.010000) [0m [0;1mSHOW FIELDS FROM elements_items [0m [4;35;1mSQL (0.010000) [0m [0mINSERT INTO elements_items (`item_id`, `element_id`, `add_flag`) VALUES (94, 3140, 0) [0m [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS FROM items_releases [0m [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases (`item_id`, `release_id`) VALUES (94, 97) [0m [4;36;1mitems_releases Columns (0.010000) [0m [0;1mSHOW FIELDS FROM items_releases [0m [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases (`item_id`, `release_id`) VALUES (91, 97) [0m [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS FROM items_releases [0m [4;35;1mSQL (0.010000) [0m [0mINSERT INTO items_releases (`item_id`, `release_id`) VALUES (92, 97) [0m [4; What would cause this? From what I understand, the column meta data should be loaded only once as each model is loaded for the first time. This happens under both Oracle and MySQL. I am running with my environment set to production. Thanks in advance, Don Mc --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don.Mc
2007-Jun-11 20:56 UTC
Re: Duplicate ''SHOW FIELDS'' statements when inserting data for production website
Any ideas,anyone? On Jun 10, 9:09 am, "Don.Mc" <Don.McCl...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am using a HABTM relationship for my app. When inserting data for a > number of collection objects, > I am seeing a ''SHOW FIELD'' query as each row is inserted: > > 0m > [4;36;1melements_tags Columns (0.020000) [0m [0;1mSHOW FIELDS > FROM elements_tags [0m > [4;35;1mSQL (0.010000) [0m [0mINSERT INTO elements_tags > (`element_id`, `tag_id`, `add_flag`) VALUES (3140, 2, NULL) [0m > [4;36;1melements_items Columns (0.010000) [0m [0;1mSHOW FIELDS > FROM elements_items [0m > [4;35;1mSQL (0.010000) [0m [0mINSERT INTO elements_items > (`item_id`, `element_id`, `add_flag`) VALUES (94, 3140, 0) [0m > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (94, 97) [0m > [4;36;1mitems_releases Columns (0.010000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (91, 97) [0m > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.010000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (92, 97) [0m > [4; > > What would cause this? From what I understand, the column meta data > should be loaded only once as > each model is loaded for the first time. This happens under both > Oracle and MySQL. I am > running with my environment set to production. > > Thanks in advance, > Don Mc--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2007-Jun-12 04:11 UTC
Re: Duplicate ''SHOW FIELDS'' statements when inserting data for production website
Don.Mc wrote:> I am using a HABTM relationship for my app. When inserting data for a > number of collection objects, > I am seeing a ''SHOW FIELD'' query as each row is inserted: > ... > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (94, 97) [0m > [4;36;1mitems_releases Columns (0.010000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (91, 97) [0m > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > FROM items_releases [0m > [4;35;1mSQL (0.010000) [0m [0mINSERT INTO items_releases > (`item_id`, `release_id`) VALUES (92, 97) [0m > [4; > > What would cause this? From what I understand, the column meta data > should be loaded only once as > each model is loaded for the first time. This happens under both > Oracle and MySQL. I am > running with my environment set to production.Rails currently doesn''t cache columns of HABTM join tables. The fix would probably only involve changing line http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb#L84 to read @columns ||= ... Give it a try, or open a ticket. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don.Mc
2007-Jun-12 13:57 UTC
Re: Duplicate ''SHOW FIELDS'' statements when inserting data for production website
Thanks! I will give it a try. Regards, Don On Jun 11, 11:11 pm, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> Don.Mc wrote: > > I am using a HABTM relationship for my app. When inserting data for a > > number of collection objects, > > I am seeing a ''SHOW FIELD'' query as each row is inserted: > > ... > > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > > FROM items_releases [0m > > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > > (`item_id`, `release_id`) VALUES (94, 97) [0m > > [4;36;1mitems_releases Columns (0.010000) [0m [0;1mSHOW FIELDS > > FROM items_releases [0m > > [4;35;1mSQL (0.020000) [0m [0mINSERT INTO items_releases > > (`item_id`, `release_id`) VALUES (91, 97) [0m > > [4;36;1mitems_releases Columns (0.020000) [0m [0;1mSHOW FIELDS > > FROM items_releases [0m > > [4;35;1mSQL (0.010000) [0m [0mINSERT INTO items_releases > > (`item_id`, `release_id`) VALUES (92, 97) [0m > > [4; > > > What would cause this? From what I understand, the column meta data > > should be loaded only once as > > each model is loaded for the first time. This happens under both > > Oracle and MySQL. I am > > running with my environment set to production. > > Rails currently doesn''t cache columns of HABTM join tables. > The fix would probably only involve changing line > > http://dev.rubyonrails.org/browser/trunk/activerecord/lib/active_reco... > > to read @columns ||= ... > > Give it a try, or open a ticket. > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2007-Jun-12 14:21 UTC
Re: Duplicate ''SHOW FIELDS'' statements when inserting data for production website
Don.Mc wrote:> Thanks! I will give it a try.Thinking about it, the change I suggested will only get rid of the last two SHOW FIELDS in your post; the join table fields will still be fetched separately for each parent object. A proper fix would have to cache the columns inside the association reflection. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Don.Mc
2007-Jun-12 14:24 UTC
Re: Duplicate ''SHOW FIELDS'' statements when inserting data for production website
OK, will look at that. Thanks again. On Jun 12, 9:21 am, Mark Reginald James <m...-bzGI/hKkdgQnC9Muvcwxkw@public.gmane.org> wrote:> Don.Mc wrote: > > Thanks! I will give it a try. > > Thinking about it, the change I suggested will only get > rid of the last two SHOW FIELDS in your post; the join table > fields will still be fetched separately for each parent object. > > A proper fix would have to cache the columns inside the > association reflection. > > -- > We develop, watch us RoR, in numbers too big to ignore.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---