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
e[4;36;1melements_tags Columns (0.020000)e[0m e[0;1mSHOW FIELDS
FROM elements_tagse[0m
e[4;35;1mSQL (0.010000)e[0m e[0mINSERT INTO elements_tags
(`element_id`, `tag_id`, `add_flag`) VALUES (3140, 2, NULL)e[0m
e[4;36;1melements_items Columns (0.010000)e[0m e[0;1mSHOW FIELDS
FROM elements_itemse[0m
e[4;35;1mSQL (0.010000)e[0m e[0mINSERT INTO elements_items
(`item_id`, `element_id`, `add_flag`) VALUES (94, 3140, 0)e[0m
e[4;36;1mitems_releases Columns (0.020000)e[0m e[0;1mSHOW FIELDS
FROM items_releasese[0m
e[4;35;1mSQL (0.020000)e[0m e[0mINSERT INTO items_releases
(`item_id`, `release_id`) VALUES (94, 97)e[0m
e[4;36;1mitems_releases Columns (0.010000)e[0m e[0;1mSHOW FIELDS
FROM items_releasese[0m
e[4;35;1mSQL (0.020000)e[0m e[0mINSERT INTO items_releases
(`item_id`, `release_id`) VALUES (91, 97)e[0m
e[4;36;1mitems_releases Columns (0.020000)e[0m e[0;1mSHOW FIELDS
FROM items_releasese[0m
e[4;35;1mSQL (0.010000)e[0m e[0mINSERT INTO items_releases
(`item_id`, `release_id`) VALUES (92, 97)e[0m
e[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.
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
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.