1. Introducing dependencies in Maven


2. Use of pagination in code



3. Source code analysis

PageHelper.startPage(page,pageSize);
Sets the page number and the number of pages to display on each page


View the source code PageInterceptor class, the implementation of the Interceptor interface



An Interceptor interface overrides the following three methods






Interceptors are defined to intercept Executor’s Query methods


The interceptor fires when the following query is executed
List<Map<String, Object>> list = detailMapper.findCourseCredits(studentCode);


Our paging logic is in the Intercept method, which is executed by the interceptor trigger






Query the total number of records first, then query the current page records



4. Performance optimization

When querying the total number of records will query all the fields, when the amount of data will lead to a very slow query speed, normally we query the total number should only query a primary key field on the line, we view the source code found



Add a findCourseCredits_COUNT query to mapper



Debug the total number of query records as written in mapper