MYSQL database access performance data to optimize the paging process

1, the client (browser or application) tab

The data is downloaded from the application server to all local applications or browser, native code by the paging process in the application or the browser

Advantages: simple coding, reducing the client and server network application number of interactions

Disadvantages: the first interactive long time client memory footprint

Adaptation scenario: the client and the application server network delay larger, but require follow-up operations smoothly, such as mobile phones GPRS, ultra remote access (across

 

2, application server paging

Download the data from the database server to all the application server, and then filter data within the application server.

Advantages: coding simple and requires only one SQL interact better with the total data paged data about the same performance.

Disadvantages: poor performance when large total amount of data.

Match the scene: the database system does not support paging processing, the amount of data is small and controllable.


3, SQL Database Paging

SQL database using SQL page requires two complete

A calculation of the total number of SQL

A data returned paging SQL

Advantages: Good performance

Disadvantages: coding complexity, a variety of different databases syntax requires two SQL interaction.

 

The following pages of two strategies:

Directly through the rownum page:

select * from (

         select a.*,rownum rn from

                   (select * from product a where company_id=? order by status) a

         where rownum<=20)

where rn>10;

Overhead for data access IO + = index index table corresponding to the result of all recording data IO

 

Paging syntax using rowid

Page optimization principle is to find records by index ROWID pure, then return data back to the table by ROWID requires inner query and sort the whole field in the index.

create index myindex on product(company_id,status);

select b.* from (

         select * from (

                   select a.*,rownum rn from

                            (select rowid rid,status from product a where company_id=? order by status) a

                   where rownum<=20)

         where rn>10) a, product b

where a.rid=b.rowid;

Data access cost index = IO + paged results index table data corresponding to IO

More technical information may concern: gzitcast

Guess you like

Origin www.cnblogs.com/heimaguangzhou/p/11689894.html