good chemistry is complicated, and a little bit messy -LW |
|
PerlMonks |
mysql's join too slow; using Perl to compare two tablesby Andre_br (Pilgrim) |
on Feb 04, 2006 at 22:25 UTC ( [id://528005]=perlquestion: print w/replies, xml ) | Need Help?? |
Andre_br has asked for the wisdom of the Perl Monks concerning the following question:
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:
From time to time, my vendors send me a .txt file with their updated inventory, wich has the following columns:
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: 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)). 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
Back to
Seekers of Perl Wisdom
|
|