I have a model called Product with an attribute called file of type :binary (DB BLOB). If I do product.save (where product is an instance of my Product model), here is SQL statement that the mysql adapter for Ruby will do: INSERT INTO `PRODUCT` COLUMNS(NAME, PRICE, FILE) VALUES(''PROD1'', 4.56, X''00DEF033423023220'') All is hunky dory for as long as my BLOB is not too big. If the blob is say 8MB (not that big actually),there is a problem: The buffer used by the mysql server(max_allowed_packet) to hold the commands must be at least 16MB (two bytes for hexadecimal representation). This is an unecessarily huge number for holding SQL commands. Is there a way to tell ruby to use a host variable in the SQL statement (i.e. VALUES(''PROD1'', 4.56, :blobvar) instead of the literal format in the example above. I cannot believe this problem has never been seen before? Imagine if the BLOB data I need to store is 100MB? Your help is much appreciated. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jean-Etienne Durand
2007-May-28 11:52 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Mario, For some reasons (design AFAIK), AR gets/update all the columns all the time. This is needed for validation. So, what you can do, is to separate your model, and put the blob in a separate one (and having a has_one relation). Jean-Etienne http://www.woa.hu -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mario Jauvin
2007-May-28 13:06 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Jean-Etienne Durand wrote:> Mario, > > For some reasons (design AFAIK), AR gets/update all the columns all the > time. This is needed for validation. > So, what you can do, is to separate your model, and put the blob in a > separate one (and having a has_one relation). > > Jean-Etienne > http://www.woa.huJean, Your comment is related to an issue where people would like to have BLOBs lazy loaded (only loaded when needed). My post is related to UPDATING (not loading) a BLOB. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jean-Etienne Durand
2007-May-28 13:14 UTC
Re: Storing large BLOBs in the database with ActiveRecord
OK, read too fast sorry. So, AR does not support parametized query. Just for info, this has been discussed a lot, since it has some performance issues on Oracle for example. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mario Jauvin
2007-May-28 13:16 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Jean-Etienne Durand wrote:> OK, read too fast sorry. > > So, AR does not support parametized query. Just for info, this has been > discussed a lot, since it has some performance issues on Oracle for > example.Jean, I am aware that AR does not support parameterized queries. My post is COULD it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mario Jauvin
2007-May-28 13:26 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Mario Jauvin wrote:> Jean-Etienne Durand wrote: >> OK, read too fast sorry. >> >> So, AR does not support parametized query. Just for info, this has been >> discussed a lot, since it has some performance issues on Oracle for >> example. > > Jean, I am aware that AR does not support parameterized queries. My > post is COULD it.Actually Jean, my question is not really could AR support parameterized queries (i.e. provide capability to AR user) but rather could it use parameterized queries internally to support updating BLOBs. This has very different implications that supporting parameterized queries in a general and user facing manner. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Mario Jauvin
2007-May-28 13:29 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Mario Jauvin wrote:> Actually Jean, my question is not really could AR support parameterized > queries (i.e. provide capability to AR user) but rather could it use > parameterized queries internally to support updating BLOBs. This has > very different implications that supporting parameterized queries in a > general and user facing manner.Change "that supporting" to "than supporting" in the text above -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jean-Etienne Durand
2007-May-28 13:30 UTC
Re: Storing large BLOBs in the database with ActiveRecord
Yes, internally of course :) Check this thread: http://www.ruby-forum.com/topic/108056 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---