IomSpace:

If speed is the issue, I'd use this approach:

  1. Create a surrogate temporary table with no indexes for each table you're loading.

  2. Bulk load your temporary tables. (I don't know MySQL, so I'm unfamiliar with its bulk data loader.)
  3. Insert new records from your temporary tables into your production tables.

    -- Only insert them if they don't exist INSERT INTO dev.blocks (names) SELECT names FROM dev.tmp_blocks WHERE names NOT IN ( SELECT names from dev.blocks ) INSERT INTO dev.vials (block_id, lt, well_position, gene, barcode) SELECT block_id, lt, well_position, gene, barcode FROM dev.tmp_vials WHERE ... clause to prevent inserting duplicates ...
  4. Drop your surrogate tables.

This way, you can let the database do the work as efficiently as possible. You'll reduce the number of transactions on the database, reduce the traffic between your server and the database server, reduce the I/O consumed by the database, etc.

...roboticus

In reply to Re: Is there a more efficient way? by roboticus
in thread Is there a more efficient way? by lomSpace

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.