Actually, perl structures with unknown lengths are not best handled by the FreezeThaw and Data::Dumper modules. Perl structures of unknown complexity are handled very well by them. Lets say I have a structure that is a string of numbers. Using freeze or nfreeze to put it in the database means that there is an operation to expand or put it away. We're starting to drift off into database design, but it's a good general principle to think about. If i need to flick something in the middle of the array the operation is:
  1. Get the record
  2. Thaw it
  3. Change the value
  4. Freeze it
  5. Put it away
If you had a series of updates to do on different arrays, it doesn't make much sense to freeze it. Another reason is that it doesn't scale very well. There is a finite amount of data that it can hold (albeit quite large).

A simple way of thinking about a flat array in a database would be (and this is how nodegroups are handled in ecore, the system that runs this site):
SELECT * FROM INCLUSIONS WHERE ARRAY_ID='42' ORDER BY ARRAY_POSITION
This scales as big as you need it, plus allows you to do mundane operations such as changing order of items, etc etc, without having to pull the entire glob out of the db and shove it back in. However, whether the SELECT or the thaw is faster depends on that dataset. YMMV.

    --jb

In reply to Re: Re: arrays in database by JayBonci
in thread arrays in database by dev2000

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.