A user has a message page, where he sees messages from other users, as well as how many unread messages from each user are shown. How to optimize database queries when a user loads a message page? Now every dialogue is checked by a cycle and counts messages and shows whether they are read or not, as a result of which there are a lot of requests on the page. Tell me how to solve a similar problem. The structure of the table http://prntscr.com/fbp9e2 .
- And the structure of the tables [s] show? (create statement) - E_p
- Get all unreads, and sort them by unread from each user at rnr - br3t
|