Well for starters i don't see any pagination on the DB level that means you load all users in memory. Try using paginate() instead of get() at your query
Mar 15, 2023
2
Level 2
Pagination and query too slow on server
I have get all users method that shows all users from database with pagination. On local everything works fine and fast but thats probably because I don't have many users in database. But when I go to server it takes one minute to open up get all users page and when I scroll down it takes same amount of time to opet ?page=2 and etc. Query calculates distance from other users based on latitude and longitude of authenticated users and shows closest users to him. My query or pagination are probably too slow and I need help on how to optimize it.
Please or to participate in this conversation.