Home > Back-end >  Want to ask how to optimize the query efficiency
Want to ask how to optimize the query efficiency

Time:11-25

I now have a users table, if the user data 10000, paging,
I need to statistics of each user has withdrawal amount
I need statistics each user at the invitation of the number of friends
I need these two data in the user list, return together, record cash withdrawals and invitation list is need to call another

I used to practice is user table paging query out first, reoccupy two SQL request withdrawal record and invited table respectively, then put the data into the user list, return together,

I want to find a most efficient SQL query train of thought,

CodePudding user response:

Find out all the withdrawal in the paging and user records and invitation?

CodePudding user response:

https://blog.csdn.net/weixin_44563573/article/details/107506825

CodePudding user response:

This is a design problem, your previous practice is in line with the current mainstream instead, use an SQL can solve the problem in the project scale is small, slightly bigger time don't suggest use too much

CodePudding user response:

Check the view, paging through view deals with directly

CodePudding user response:

Query the user's time, use inline query group by clause table fields and Count the number of child table,

CodePudding user response:

Your ideas are right, the first with the paging user ID are found out, this as a condition to the extracted amount and invited, not recommended for solving the three tables link again

CodePudding user response:

Can add index, fast query, but add slow and so on,

CodePudding user response:

This to improve efficiency, you must build index, the field is used to query indexed

CodePudding user response:

In the user table to add two fields, write a trigger to update the two fields
  • Related