I have 3 tables:
[users] 1 ----------- n [evaluations] n --------- 1 [items]
Where evaluation can be positive (valuation: true ) or negative (valuation: false ), I need a method that returns all items that the user liked and did not like ... For this I did the following method in the user model:
%pre%
The same principle was adopted for the method for the dislike method
The idea is to do this with many users, the problem is that it is taking a long time to return the data. Is there any way to improve the performance of this code snippet? Any structure that I can keep on the server, because this query is executed many times more than once per user ...
______ azszpr28800 ___
I had the idea of trying to do directly in the bank to simplify the process and modified the function to:
%pre%
I've had an improvement of 0.2 seconds in the average ... I'm putting it as an answer because I do not think it will improve more than that, but if someone wants to prove me to the contrary the answer will be very welcome!
______ azszpr36666 ___
Would not it be less expensive if you paginated?
You can use the library
link
so it will return the paged items I believe will shorten the search time.
___