This is a shoutout to Laravel’s Query Builder method distinct(). I feel sad and embarrassed that I didn’t know about it sooner. There are a lot of instances where I need to get a column’s unique values. And instead of using groupBy() and wasting a lot of resources.
You can use distinct(), which will search for distinct instances instead of retrieving each one and grouping them.
This saves a significant amount of time and memory.
Just thought distinct() deserves it’s own post.