Monks,

I am continuing in my journey with DBIX::Class. Honestly, I am not sure that I see as much, if any, value in it relative to straight perl and DBI; however, I know enough to know that you sometimes cannot see value until you work at it long enough. So ...

My testbed is an application that hits various public web services to collect information and store it in a SQLite database. I have quite a bit working functionally at this time; however, insert performance into the database is horrible with the default of Auto_Commit = 1. My test code shows almost a 100X improvement if I went to native DBI and used transactions comitting every 1000 records in a total of 750K records.

My quandry, err question, lies into how best use transactions with DBIX::Class. The online documentation almost reads like we support transactions, but don't use them because our code is wonderful. But if you do use them, keep Auto_Commit = 1 and use the DBIX::Class::Schema txn_do method and we will still do wonderful things. And lastly, if this doesn't work for you, you can use txn_begin, txn_commit and txn_rollback but its absolutely you fault, which it is anyway, if anything goes wrong.

When performing a large number of inserts or updates with DBIX::Class, what is the fastest, recommend pattern to use?

I like the thought of txn_do for applications that don't have the speed criticality above; however, I cannot find much documentation on the advantages and disadvantages of it. I seem to only find the module documentation or snippets of it reformatted. Are there any good reads on this method?

Thanks in advance,

lbe


In reply to DBIX::Class and transactions by learnedbyerror

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.