Salam Alikom guys
if you use whereIn() for a query on integer values like this:
Post::whereIn('id',[1,2,3])->get() then there are other good choices to do this:
the
find()method yes it accepts array of ids alsoPost::find([1,2,3])the
whereIntegerInRaw()method like this:
Post::whereIntegerInRaw('id',[1,2,3])->get()also there is another version likewhereNotInwhich iswhereIntegerNotInRaw().
And here are the performance results of using these methods to get data in id using 10000 ids :
find(rang(1,10000)): 30 mswhereIntegerInRaw('id',range(1,10000)): 34 mswhereIn('id', range(1,10000)): 500 ms
That's it!
Thank you :)
Top comments (0)