Is it possible to store data from one form in two separate mysql tables?
I need to do this because the amount of data which can be submitted via
the form, exceeds the maximum mysql row size.
That's a lot of data given that the size limit is 65535 (and blobs/
texts only count a few bytes towards that)!
You pretty much need to just do it. Put some of the data from the
params hash into one object and the rest into another. Probably create
an association between these two models.
Thanks for the answer Fred.
I am understanding the definition of row size correctly, aren't I?
What is happening is that I have a form (with loads of fields - some
allowing up to 4000 characters).
When a user enters an average amount of data, then the form submits and
everything is good.
When the user however enters more than an average amount of data and
presses submit, the following error message is thrown:
ActiveRecord::StatementInvalid (Mysql::Error: Got error 139 from storage
engine: ...
I did a lot of Googling for "maximum size of a mysql record" and kept
finding references to the max. row size (which is, as you say 65535).
I took row size to mean the size of one data set (i.e. everything that
gets submitted with the form).
Is this correct or am I missing something obvious?
Thanks very much for your help.
Thanks for the answer Fred.
I am understanding the definition of row size correctly, aren't I?
What is happening is that I have a form (with loads of fields - some
allowing up to 4000 characters).
When a user enters an average amount of data, then the form submits and
everything is good.
When the user however enters more than an average amount of data and
presses submit, the following error message is thrown:
ActiveRecord::StatementInvalid (Mysql::Error: Got error 139 from storage
engine: ...
I did a lot of Googling for "maximum size of a mysql record" and kept
finding references to the max. row size (which is, as you say 65535).
I took row size to mean the size of one data set (i.e. everything that
gets submitted with the form).
Row size is to do with the size of one row in the database. If what
you submit in your form ends up in multiple activerecord objects then
you're dealing with multiple rows, each one of which could be as big
as the row size limits permit. googling around also suggests that 139
can mean that mysql ran out of memory
Yeah, I found it a bit bizarre as I have reprogrammed this form in RoR.
Previously it was in PHP and could deal with data of this magnitude
without problems.
I guess I'll keep Googling and see if I come up with anything as
splitting the data into two tables seems an ugly solution.
I wouldn't recommend storing a single object in two tables or
splitting it across multiple rows. You'll be fighting this complexity
elsewhere in your code and it will become a real headache.
Are you including images or something in your object? If so, you'd be
much better off attaching them to your object with something like
Paperclip (http://github.com/thoughtbot/paperclip/tree/master). This
will just add a reference to the file to your object and store the
data elsewhere (filesystem or Amazon S3). The filesystem is much
better at storing large amounts of data than the database.
Amazon S3 doesn't take much more effort to set up and has the
advantage of making your attachment available across multiple servers
that don't share the same filesystem.