steur;10946639 wrote:Hi everyone,
What I'm trying to do is this:
Read all records from a table in my database and compare it to an array of data that I have.
So I want to basically see if I havent already inserted this data OR if the data in the database in incomplete compared to the new data in the array.
Based on this information I'll ofc want to NOT insert data or merge data.
Now, I'm pretty new at php but I guess i can't get around using nested foreach loops? One for my database records and one for my array of records? This is a huge problem because im working with tens of thousands of records...
Any help would be great
Cheers
Hi my personal working experience is whenever a task require to manipulate with thousands and thousands or even involve millions of records, using a programming language be it C,C++,Java or for your case PHP to fetch them out and compare will not give the optimal performance. Very often we have to resort to the database proprietary stored procedures or SQL syntax.
Since I my job deal mainly with rcle, they offer something MERGE INTO .. syntax. For your case you can create a temp table and use the sqlldr to load your array of data. Then you can create index on that temp table. Then you use the MERGE INTO ... syntax to cross check the your table against that temp table and then depend on business logic to update or insert using a SINGLE SQL.
Please note above is proprietary solution but if it can give me the performance I want, I gotta bow to reality isn't it ? :quiet: