Hello esteemed fellow monks

I hope you guys can help me on this. Hereīs the problem: I have a table named 'catalog', thatīs where the products are kept. Itīs something like this:

table 'catalog' product_id author title label description price vendor_id log
From time to time, my vendors send me a .txt file with their updated inventory, wich has the following columns:
author title label description price

So, thatīs when I have to check wich CDs are new at theis inventory, you know? I could just erase their entire online inventory, and then record the new one theyīve just sent, but this ainīt good because itīs important that the product_ids of the veteran products donīt change, you know?

Then, what I do? I insert the bew data on a table I call 'pivot', wich has the same fields as the ones send me, and also a received_id:

table 'pivot' received_id author title label description price
Then I perform this inner join below, to find out the received_ids for the products that are in fact veteran (wich will be erased from the 'pivot' table before inserting the remaining into the catalog (so there are only new products there)).
select pivot.received_id from catalog inner join pivot on ( catalog.author = pivot.author and catalog.titulo = pivot.titulo and catalog.label = pivot.label and catalog.description = pivot.description and catalog.price = pivot.price );
The problem is this inner join with multiple ons takes too much effort and time - weīre talking about a 100k records inner join! I was looking for another way to compare these two tables without this inner join, but it occurs to me now that maybe I could use Perl instead of mysql.

I could, insted of using this 'pivot' table, load the 'catalog' data into an array - being each element a concatenation like ('thisauthor thistitle thislabel thisdescription thisprice', 'thisanotherauthor thisanothertitle thisanotherlabel thisanotherdescription thisanotherprice', ...) and so on. Then I could do the same with the data the vendor sends me, and then find out the redundant ones with grep. Well, donīt know it this will sound like an heresy, sorry if it does.

What do you think about?

Thanks a lot!

Andre


In reply to mysql's join too slow; using Perl to compare two tables by Andre_br

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.