Support the ongoing development of Laravel.io →
Laravel Database Eloquent
Last updated 2 years ago.
0

Rather than looping over every item in the DB, can you run a select query to check for duplicates? I don't know exactly what you're trying to compare, but something like this might do the trick:

https://stackoverflow.com/a/688551

0

@Ben Sampson , I have to insert new user to the table which contains 5 million records. I have to check whether this new user is already present in table or not. If not, then insert user else update his rating.

0

Ok, I would approach it by looping over each new user to be added (can't tell if you're adding just 1 or more than 1 user at a time). You can run a select query to see if they exist in the table already, if they do, update them. If they don't then insert them.

0

@Ben Sampson,Thanks. will approach as same as you.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

DPS dps Joined 30 May 2018

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.