CN112416967A - Data paging query method and device, electronic equipment and storage medium - Google Patents
Data paging query method and device, electronic equipment and storage medium Download PDFInfo
- Publication number
- CN112416967A CN112416967A CN202011460731.6A CN202011460731A CN112416967A CN 112416967 A CN112416967 A CN 112416967A CN 202011460731 A CN202011460731 A CN 202011460731A CN 112416967 A CN112416967 A CN 112416967A
- Authority
- CN
- China
- Prior art keywords
- query
- page
- next page
- paging
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000000034 method Methods 0.000 title claims abstract description 71
- 238000004891 communication Methods 0.000 claims description 21
- 238000004590 computer program Methods 0.000 claims description 14
- 230000004044 response Effects 0.000 claims description 8
- 238000013500 data storage Methods 0.000 abstract description 10
- 239000012634 fragment Substances 0.000 description 11
- 238000010586 diagram Methods 0.000 description 6
- 230000009286 beneficial effect Effects 0.000 description 5
- 238000013467 fragmentation Methods 0.000 description 3
- 238000006062 fragmentation reaction Methods 0.000 description 3
- 230000003287 optical effect Effects 0.000 description 2
- 230000001174 ascending effect Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 238000009472 formulation Methods 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000008520 organization Effects 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/242—Query formulation
- G06F16/2433—Query languages
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/248—Presentation of query results
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/28—Databases characterised by their database models, e.g. relational or object models
- G06F16/284—Relational databases
- G06F16/285—Clustering or classification
- G06F16/287—Visualization; Browsing
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- Data Mining & Analysis (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Mathematical Physics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention provides a data paging query method, a data paging query device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring additional conditions corresponding to the next page according to the query result of the current page; and sending the page turning instruction and the additional condition corresponding to the next page to the server, so that the server responds to the page turning instruction, generates and executes an inquiry statement for acquiring the inquiry result of the next page according to the inquiry condition, the paging parameter and the additional condition corresponding to the next page, and acquires the inquiry result of the next page. According to the data paging query method, the data paging query device, the electronic equipment and the storage medium, the additional condition corresponding to the next page is obtained according to the query result of the current page and is sent to the server, so that the server generates and executes a query statement according to the query condition, the paging parameter and the additional condition corresponding to the next page, the query result of the next page is obtained, and the query performance of continuous page turning under the condition of mass data storage can be improved.
Description
Technical Field
The present invention relates to the field of computer technologies, and in particular, to a data paging query method and apparatus, an electronic device, and a storage medium.
Background
The data paging is to search the data content to be displayed according to the number of pages specified by the user in the case of large data volume, and to search only part of the data each time and display the data content by page.
For a database (for example, MySQL) using middleware such as MyCat, etc., when performing paging query and sorting returned data according to time, in the prior art, the query is performed through a paging query page statement carrying a query condition, and the paging query page statement is distributed to each segment of the database to be executed.
For example, a paged query page statement is
select from operation log create time between startup time and end time and operation type ip and ip. Accordingly, the number of the first and second electrodes,
page 1 the statements executed on the respective slices are: select from operation log.. limit 0, $ pageNum;
page 2 the statements executed on the respective slices are: select from operation log.. limit 0, $ pageNum 2;
page 3 the statements executed on the respective slices are: select from operation log.. limit 0, $ pageNum 3;
the n-th page executes the statements on the respective slices as follows: select from operation log. limit 0, $ pageNum n.
By the method, the results returned by each fragment need to be summarized and sorted, in the direct paging mode, the initial offset of limit at each time is 0, and the amount of data returned by each fragment is larger and larger, so that the continuous paging query performance of mass data is gradually degraded, and the performance is degraded after the number of pages is more, so that the fragment query is overtime or memory overflow is finally caused.
Disclosure of Invention
The invention provides a data paging query method, a data paging query device, electronic equipment and a storage medium, which are used for solving the defect of poor query performance in the prior art and realizing high-performance paging query.
The invention provides a data paging query method, which comprises the following steps:
acquiring additional conditions corresponding to the next page according to the query result of the current page;
and sending the page turning instruction and the additional condition corresponding to the next page to a server, so that the server responds to the page turning instruction, generates and executes a query statement for obtaining a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and obtains the query result of the next page.
According to the data paging query method provided by the invention, after the page turning instruction and the additional condition corresponding to the next page are sent to the server, the method further comprises the following steps:
and receiving the query result of the next page sent by the server.
According to the data paging query method provided by the invention, the specific step of acquiring the additional condition corresponding to the next page according to the query result of the current page comprises the following steps:
acquiring target parameters in the last line of data in the query result of the current page;
and acquiring the additional condition corresponding to the next page according to the target parameter in the last line of data in the query result of the current page.
According to the data paging query method provided by the invention, the target parameters comprise a main key and an index.
The invention also provides a data paging query method, which comprises the following steps:
receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page;
responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, executing the query statement, and acquiring the query result of the next page;
and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
According to the data paging query method provided by the present invention, in response to the page turning instruction, generating and executing a query statement for obtaining a query result of a next page according to a query condition, a paging parameter, and an additional condition corresponding to the next page, and after obtaining the query result of the next page, the method further includes:
and sending the query result of the next page to the terminal.
The invention also provides a data paging query device, comprising:
the acquisition module is used for acquiring the additional condition corresponding to the next page according to the query result of the current page;
and the first communication module is used for sending the page turning instruction and the additional condition corresponding to the next page to a server, so that the server responds to the page turning instruction, generates and executes a query statement for obtaining a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and obtains the query result of the next page.
The invention also provides a data paging query device, comprising:
the second communication module is used for receiving a page turning instruction sent by the terminal and an additional condition corresponding to a next page;
the query module is used for responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, executing the query statement and acquiring the query result of the next page;
and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
The invention further provides an electronic device, which includes a memory, a processor and a computer program stored in the memory and capable of running on the processor, wherein the processor implements the steps of any of the above data paging query methods when executing the computer program.
The present invention also provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, performs the steps of the data paging query method as described in any one of the above.
According to the data paging query method, the data paging query device, the electronic equipment and the storage medium, the additional condition corresponding to the next page is obtained according to the query result of the current page and is sent to the server, so that the server generates and executes the query statement for obtaining the query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, the query result of the next page is obtained, and the query performance of continuous page turning under the condition of mass data storage can be improved. Furthermore, according to the additional condition corresponding to each page, the query range can be gradually reduced, and the efficiency of paging query can be improved.
Drawings
In order to more clearly illustrate the technical solutions of the present invention or the prior art, the drawings needed for the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and those skilled in the art can also obtain other drawings according to the drawings without creative efforts.
FIG. 1 is a flow chart illustrating a data paging query method according to the present invention;
FIG. 2 is a flow chart illustrating a data paging query method according to the present invention;
FIG. 3 is a schematic structural diagram of a data paging query apparatus according to the present invention;
FIG. 4 is a schematic structural diagram of a data paging query apparatus according to the present invention;
fig. 5 is a schematic structural diagram of an electronic device provided in the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings, and it is obvious that the described embodiments are some, but not all embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the description of the embodiments of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", and the like indicate orientations or positional relationships based on the orientations or positional relationships shown in the drawings, and are only for convenience in describing the embodiments of the present invention and simplifying the description, but do not indicate or imply that the referred devices or elements must have specific orientations, be configured in specific orientations, and operate, and thus, should not be construed as limiting the embodiments of the present invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance, and not order.
In the description of the embodiments of the present invention, it should be noted that, unless explicitly stated or limited otherwise, the terms "mounted," "connected," and "connected" are to be construed broadly, and may be, for example, fixedly connected, detachably connected, or integrally connected; can be mechanically or electrically connected; they may be connected directly or indirectly through intervening media, or they may be interconnected between two elements. Specific meanings of the above terms in the embodiments of the present invention can be understood in specific cases by those of ordinary skill in the art.
In order to overcome the problems in the prior art, the invention provides a data paging Query method, a device, an electronic device and a storage medium, and the inventive concept is that by optimizing an SQL (Structured Query Language) statement, the Query statement does not contain LIMIT 0, n × pageSize any more, so that each segment does not need to return acquired data, and the problem that the continuous paging Query performance of mass data is gradually degraded as more and more data are returned by each segment along with page turning is avoided.
Fig. 1 is a schematic flow chart of a data paging query method provided in the present invention. The data paging query method according to the embodiment of the present invention is described below with reference to fig. 1. As shown in fig. 1, the method includes: step 101, acquiring an additional condition corresponding to a next page according to a query result of the current page.
Specifically, the main execution body of the data paging query method provided by the embodiment of the present invention is a terminal. The terminal is in communication connection with the server, the terminal is located at the front end, and the server is located at the rear end. The terminal sends the original query statement carrying the query condition and the paging parameter to the server, and the server executes the original query statement, queries each fragment of the database, obtains the query result of the home page and returns the query result of the home page to the terminal.
And the paging parameter is used for limiting the row number of the data in each page. The paging parameter may be a preset number of rows. The specific value of the paging parameter is not specifically limited in the embodiments of the present invention.
Each piece of data corresponds to a row in the page.
It should be noted that, before the step 101, it is further included to determine whether the number of rows of data in the query result of the current page is less than the paging parameter.
If the number of rows of data in the query result of the current page is judged to be less than the paging parameter, indicating that all the query results are obtained, then no query is performed;
if it is determined that the number of rows of data in the query result of the current page is equal to the paging parameter, which indicates that all query results have not been obtained, step 101 is executed.
The query condition may include a query formulation and a ranking condition for the query.
And the searching formula is used for judging whether each piece of data in the database fragment is a query result meeting the condition.
And the sorting condition is used for sorting the query result of each page, and the sorting basis is the sorting condition. The sorting conditions may include fields for sorting, and sorting (ascending or descending). The field used for sorting may be referred to as a sort field.
It can be understood that the home page is the first current page, and after the terminal obtains the query result of the current page, since the query result of the current page is obtained after being performed according to the sorting condition, which data in the database has been queried can be determined according to the range of the values of the sorting fields of each row of data in the query result of the current page, so that the query range corresponding to the query result of the next page can be used as an additional condition corresponding to the next page.
And the additional condition corresponding to the next page is used for limiting the query range corresponding to the query result of the next page. Therefore, the query result of the next page is obtained by querying and sorting according to the query condition in the query range.
The part of the database excluding the obtained query result of each page can be used as an additional condition corresponding to the next page.
And 102, sending the page turning instruction and the additional condition corresponding to the next page to the server, so that the server responds to the page turning instruction, generates and executes a query statement for obtaining a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and obtains the query result of the next page.
Specifically, after acquiring the additional condition corresponding to the next page, the terminal may send the page turning instruction and the additional condition corresponding to the next page to the server.
And the page turning instruction is used for indicating the server to inquire the next page and acquiring the inquiry result of the next page.
It can be understood that, the server has obtained the query condition and the paging parameter according to the original query statement, and after receiving the page turning instruction and the additional condition corresponding to the next page, the server makes a corresponding response to the page turning instruction, and when the second page is the next page, the server may add the additional condition corresponding to the second page to the original query statement to generate the query statement corresponding to the second page. And the query statement corresponding to the second page is used for acquiring the query result of the second page. And the server side acquires data meeting the conditions and sorts the data as a query result of the second page by executing the query statement corresponding to the second page.
When any page behind the second page is the next page, the server can modify the additional condition corresponding to the current page into the additional condition corresponding to the next page on the basis of the query statement corresponding to the current page, and generate the query statement corresponding to the next page. And the query statement corresponding to the next page is used for acquiring the query result of the next page. And the server side acquires data meeting the conditions and sequences the data as a query result of the next page by executing the query statement corresponding to the next page.
It should be noted that, in the conventional data paging query method, the server returns the query result of each page according to the original query statement, and for each page, each segment needs to return the acquired data (the query result of each page before the page). In the embodiment of the invention, for each page, each fragment is queried in the part excluding the query result of each page before the page, the query result of each page before the page does not need to be returned, the phenomenon that more and more data are returned along with page turning of each fragment does not occur, and the continuous paging query performance of mass data is not gradually degraded.
According to the embodiment of the invention, the additional condition corresponding to the next page is obtained according to the query result of the current page and is sent to the server, so that the server generates and executes the query statement for obtaining the query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and the query result of the next page is obtained, thereby improving the query performance of continuous page turning under the condition of mass data storage. Furthermore, according to the additional condition corresponding to each page, the query range can be gradually reduced, and the efficiency of paging query can be improved.
Based on the content of any of the above embodiments, after sending the page turning instruction and the additional condition corresponding to the next page to the server, the method further includes: and receiving the query result of the next page sent by the server.
Specifically, the server executes the additional condition corresponding to the next page, acquires the query result of the next page, and then sends the query result of the next page to the terminal.
And the terminal receives the query result of the next page sent by the server, takes the query result of the next page as a new current page, and executes the step 101 and the step 102 to perform subsequent paging query until the query results of all pages are obtained.
According to the embodiment of the invention, the query result of the next page sent by the server is received, so that the query result of the next page can be used as the query result of the new current page to perform subsequent paging query until the query results of all pages are obtained, and the query performance of continuous page turning under the condition of mass data storage can be improved.
Based on the content of any of the embodiments, the specific step of obtaining the additional condition corresponding to the next page according to the query result of the current page includes: and acquiring target parameters in the last line of data in the query result of the current page.
Specifically, the target parameter is a value of the sorting field.
After the terminal obtains the query result of the current page, the terminal can sort the values of the fields according to the last line of data in the query result of the current page. As a target parameter in the last line of data in the query result for the current page.
And acquiring the additional condition corresponding to the next page according to the target parameter in the last line of data in the query result of the current page.
Specifically, since the sorting field is used for sorting, the target parameter in the last line of data in the query result of the current page may represent the range corresponding to the obtained query result of each page, and the query result of each subsequent page may be obtained by excluding the part of the database other than the range corresponding to the obtained query result of each page for querying and sorting. Therefore, according to the target parameter in the last line of data in the query result of the current page, the additional condition corresponding to the next page can be obtained.
According to the method and the device for page searching, the additional condition corresponding to the next page is obtained according to the target parameter in the last line of data in the query result of the current page, the query range can be gradually reduced, the efficiency of page searching can be improved, and the query performance of continuous page turning under the condition of mass data storage can be improved.
Based on the contents of any of the above embodiments, the target parameter includes a primary key and an index.
Specifically, the target parameters may include a primary key and an index.
For example, for the table operation _ log (operation log table), there are fields: id (globally unique identifier, UUID), create _ time (creation time), operation _ type (operation type), ip (machine ip address), mac (machine mac address), user _ id (user id), org _ id (organization id); the fragment field is id, and the fragment algorithm is hash algorithm; the sort field may be id (primary key) and create _ time (index).
The home page uses the original query statement:
select*from operate_log where create_time between$startTime and$endTime and operate_type=$operateType and ip=$ip and...order by create_time desc,id limit 0,$pageNum
the $ X mark in the SQL statement represents a variable, and the terminal records the create _ time and id of the last line of data and transmits the record to the back end in the subsequent page turning.
In the subsequent paging inquiry, the server limits the inquiry range of data by using the minimum create _ time and the maximum id transmitted by the terminal as additional conditions, and limits the number of pieces by using the limit.
The query statement for each page thereafter is as follows:
select*from operate_log where create_time between$startTime and$endTime and operate_type=$operateType and ip=$ip and...and(create_time<$prePageLastCreateTime or(create_time=$prePageLastCreateTime and id>prePageLastId))order by create_time desc,id limit$pageNum
by combining the create _ time and the id, the orderliness and the uniqueness of the data can be guaranteed, and the limit line number can guarantee that the query of the SQL statement sent to the bottom layer by the plug-ins such as Mycat and the like cannot exceed the limit.
According to the embodiment of the invention, the main key and the index are used as the target parameters, so that the query range can be gradually reduced according to the target parameters, the efficiency of paging query can be improved, and the query performance of continuous page turning under the condition of mass data storage can be improved.
To facilitate understanding of the above examples of the present invention, the following description is given by way of example.
In this example, a Mycat cluster has been deployed. There are 16 fragments under Mycat.
Table structure definition:
CREATE TABLE`operate_log`(`id`varchar(32)NOT NULL,`create_time`datetime NULL,`opereate_type`tinyint NULL,`ip`int NULL,`mac`varchar(255)NULL,`user_id`varchar(32)NULL,`org_id`varchar(32)NULL,`user_name`varchar(32)NULL,`org_name`varchar(32)NULL,`org_path`varchar(255)NULL,`operate_detail`varchar(255)NULL,PRIMARY KEY(`id`),INDEX`index_create_time`(`create_time`))
the fragmentation mode of configuring the Mycat table is hash fragmentation, and the fragmentation field is id
Add 1 hundred million pieces of data to the table by Mycat.
And (3) home page query: assume the time range is 2020-01-0100: 00-2021-01-0100: 00:00 and a page size of 30 rows.
The original query statement is:
select*from operate_log where create_time between‘2020-01-01 00:00:00’and‘2021-01-01 00:00:00’order by create_time desc,id limit 0,30
wherein, create _ time between '2020-01-0100: 00: 00' and '2021-01-0100: 00: 00' is the search formula in the query condition, create _ time desc, id is the sorting condition in the query condition, and 30 is the paging parameter.
Assume that the createTime of the last piece of data returned is 2020-01-0200: 00:00, id is 0000112d547142c2b2ea5bc68a6549 fe.
The query statement for the second page is:
select*from operate_log where create_time between‘2020-01-01 00:00:00’and‘2021-01-01 00:00:00’and(create_time<’2020-01-02 00:00:00’or(create_time=’2020-01-02 00:00:00’and id>0000112d547142c2b2ea5bc68a6549fe))order by create_time desc,id limit 30
wherein, create _ time < ' 2020-01-0200: 00:00 ' or (create _ time ═ 2020-01-0200: 00:00 ' and id >0000112d547142c2b2ea5bc68a6549fe) is an additional condition corresponding to the second page.
And in the subsequent query statement, replacing the additional condition corresponding to the next page.
Fig. 2 is a schematic flow chart of a data paging query method provided in the present invention. Based on the content of any of the above embodiments, as shown in fig. 2, a data paging query method includes: step 201, receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page.
And acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
Specifically, the execution subject of the data paging query method provided by the embodiment of the present invention is a server. The terminal is in communication connection with the server, the terminal is located at the front end, and the server is located at the rear end. The terminal sends the original query statement carrying the query condition and the paging parameter to the server, and the server executes the original query statement, queries each fragment of the database, obtains the query result of the home page and returns the query result of the home page to the terminal.
The next page, may be the pages starting from the second page.
And after the terminal receives the query result of the current page returned by the server, acquiring the additional condition corresponding to the next page according to the query result of the current page.
And the additional condition corresponding to the next page is used for limiting the query range corresponding to the query result of the next page. Therefore, the query result of the next page is obtained by querying and sorting according to the query condition in the query range.
The terminal may use a portion of the database excluding the query result of each acquired page as an additional condition corresponding to the next page.
After acquiring the additional condition corresponding to the next page, the terminal can send the page turning instruction and the additional condition corresponding to the next page to the server, and the server receives the page turning instruction and the additional condition corresponding to the next page.
And the page turning instruction is used for indicating the server to inquire the next page and acquiring the inquiry result of the next page.
Specifically, after receiving the page turning instruction and the additional condition corresponding to the next page, the server performs a corresponding response to the page turning instruction, and when the second page is the next page, the server may add the additional condition corresponding to the second page on the basis of the original query statement to generate the query statement corresponding to the second page. And the query statement corresponding to the second page is used for acquiring the query result of the second page. And the server side acquires data meeting the conditions and sorts the data as a query result of the second page by executing the query statement corresponding to the second page.
When any page behind the second page is the next page, the server can modify the additional condition corresponding to the current page into the additional condition corresponding to the next page on the basis of the query statement corresponding to the current page, and generate the query statement corresponding to the next page. And the query statement corresponding to the next page is used for acquiring the query result of the next page. And the server side acquires data meeting the conditions and sequences the data as a query result of the next page by executing the query statement corresponding to the next page.
According to the embodiment of the invention, the query statement for obtaining the query result of the next page is generated and executed according to the query condition, the paging parameter and the additional condition corresponding to the next page, and the query result of the next page is obtained, so that the query performance of continuous page turning under the condition of mass data storage can be improved. Furthermore, according to the additional condition corresponding to each page, the query range can be gradually reduced, and the efficiency of paging query can be improved.
Based on the content of any of the above embodiments, in response to the page-turning instruction, generating and executing a query statement for obtaining a query result of a next page according to the query condition, the paging parameter, and an additional condition corresponding to the next page, and after obtaining the query result of the next page, the method further includes: and sending the query result of the next page to the terminal.
Specifically, the server executes the additional condition corresponding to the next page, acquires the query result of the next page, and then sends the query result of the next page to the terminal.
And the terminal receives the query result of the next page sent by the server, and takes the query result of the next page as a new current page, so as to perform subsequent paging query until the query results of all pages are obtained.
According to the embodiment of the invention, the query result of the next page is sent to the terminal, so that the query result of the next page can be used as the query result of the new current page to perform subsequent paging query until the query results of all pages are obtained, and the query performance of continuous page turning under the condition of mass data storage can be improved.
The data paging query device provided by the present invention is described below, and the data paging query device described below and the data paging query method described above may be referred to in correspondence with each other.
Fig. 3 is a schematic structural diagram of a data paging query apparatus according to an embodiment of the present invention. Based on the content of any of the above embodiments, as shown in fig. 3, the apparatus includes an obtaining module 301 and a first communication module 302, where:
an obtaining module 301, configured to obtain an additional condition corresponding to a next page according to a query result of a current page;
the first communication module 302 is configured to send the page turning instruction and the additional condition corresponding to the next page to the server, so that the server, in response to the page turning instruction, generates and executes an inquiry statement for obtaining an inquiry result of the next page according to the inquiry condition, the paging parameter, and the additional condition corresponding to the next page, and obtains an inquiry result of the next page.
Specifically, the acquisition module 301 and the first communication module 302 are electrically connected.
The obtaining module 301 may determine which data in the database has been queried according to the range of the value of the sorting field of each row of data in the query result of the current page, and may use a portion of the database excluding the query result of each obtained page as an additional condition corresponding to the next page.
After acquiring the additional condition corresponding to the next page, the first communication module 302 may send the page turning instruction and the additional condition corresponding to the next page to the server.
The server side obtains the query condition and the paging parameter according to the original query statement, after receiving the page turning instruction and the additional condition corresponding to the next page, the server side makes a corresponding response to the page turning instruction, and when the second page is the next page, the server side can add the additional condition corresponding to the second page on the basis of the original query statement to generate the query statement corresponding to the second page. And the query statement corresponding to the second page is used for acquiring the query result of the second page. And the server side acquires data meeting the conditions and sorts the data as a query result of the second page by executing the query statement corresponding to the second page.
When any page behind the second page is the next page, the server can modify the additional condition corresponding to the current page into the additional condition corresponding to the next page on the basis of the query statement corresponding to the current page, and generate the query statement corresponding to the next page. And the query statement corresponding to the next page is used for acquiring the query result of the next page. And the server side acquires data meeting the conditions and sequences the data as a query result of the next page by executing the query statement corresponding to the next page.
It should be noted that the obtaining module 301 is specifically configured to, if it is determined that the number of rows of data in the query result of the current page is equal to the paging parameter, obtain an additional condition corresponding to a next page according to the query result of the current page.
The first communication module 302 is further configured to receive a query result of a next page sent by the server.
The obtaining module 301 may include:
the parameter acquisition unit is used for acquiring target parameters in the last line of data in the query result of the current page;
and the additional condition acquisition unit is used for acquiring the additional condition corresponding to the next page according to the target parameter in the last line of data in the query result of the current page.
The data paging query device provided in the embodiment of the present invention is configured to execute the data paging query method of the present invention, and an implementation manner of the data paging query device is consistent with an implementation manner of the data paging query method provided in the present invention, and the same beneficial effects can be achieved, and details are not repeated here.
The data paging query device is used for the data paging query method in the foregoing embodiments. Therefore, the description and definition in the data paging query method in the foregoing embodiments may be used for understanding the execution modules in the embodiments of the present invention.
According to the embodiment of the invention, the additional condition corresponding to the next page is obtained according to the query result of the current page and is sent to the server, so that the server generates and executes the query statement for obtaining the query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and the query result of the next page is obtained, thereby improving the query performance of continuous page turning under the condition of mass data storage. Furthermore, according to the additional condition corresponding to each page, the query range can be gradually reduced, and the efficiency of paging query can be improved.
Fig. 4 is a schematic structural diagram of a data paging query apparatus according to an embodiment of the present invention. Based on the content of any of the above embodiments, as shown in fig. 4, the apparatus includes a second communication module 401 and a query module 402, where:
the second communication module 401 is configured to receive a page turning instruction sent by the terminal and an additional condition corresponding to a next page;
the query module 402 is configured to, in response to the page turning instruction, generate a query statement for obtaining a query result of the next page according to the query condition, the paging parameter, and an additional condition corresponding to the next page, and execute the query statement to obtain the query result of the next page;
and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
Specifically, the second communication module 401 and the query module 402 are electrically connected.
After acquiring the additional condition corresponding to the next page, the terminal may send the page turning instruction and the additional condition corresponding to the next page to the server, and the server may receive the page turning instruction and the additional condition corresponding to the next page through the second communication module 401.
The query module 402 responds to the page turning instruction, and when the second page is the next page, the query module 402 may add an additional condition corresponding to the second page to the original query statement to generate a query statement corresponding to the second page. And the query statement corresponding to the second page is used for acquiring the query result of the second page. The query module 402 obtains the data meeting the condition by executing the query statement corresponding to the second page and sorts the data as the query result of the second page.
When any page after the second page is the next page, the query module 402 may modify the additional condition corresponding to the current page into the additional condition corresponding to the next page on the basis of the query statement corresponding to the current page, and generate the query statement corresponding to the next page. And the query statement corresponding to the next page is used for acquiring the query result of the next page. The query module 402 obtains data meeting the conditions by executing the query statement corresponding to the next page and sorts the data as the query result of the next page.
The second communication module 401 is further configured to send the query result of the next page to the terminal.
The data paging query device provided in the embodiment of the present invention is configured to execute the data paging query method of the present invention, and an implementation manner of the data paging query device is consistent with an implementation manner of the data paging query method provided in the present invention, and the same beneficial effects can be achieved, and details are not repeated here.
The data paging query device is used for the data paging query method in the foregoing embodiments. Therefore, the description and definition in the data paging query method in the foregoing embodiments may be used for understanding the execution modules in the embodiments of the present invention.
According to the embodiment of the invention, the query statement for obtaining the query result of the next page is generated and executed according to the query condition, the paging parameter and the additional condition corresponding to the next page, and the query result of the next page is obtained, so that the query performance of continuous page turning under the condition of mass data storage can be improved. Furthermore, according to the additional condition corresponding to each page, the query range can be gradually reduced, and the efficiency of paging query can be improved.
Fig. 5 illustrates a physical structure diagram of an electronic device, which may include, as shown in fig. 5: a processor (processor)510, a communication Interface (Communications Interface)520, a memory (memory)530 and a communication bus 540, wherein the processor 510, the communication Interface 520 and the memory 530 communicate with each other via the communication bus 540. Processor 510 may invoke logical instructions stored in memory 530 and executable on processor 510 to perform the data paging query method provided by the above-described method embodiments, the method comprising: acquiring additional conditions corresponding to the next page according to the query result of the current page; sending the page turning instruction and the additional condition corresponding to the next page to the server, so that the server responds to the page turning instruction, generates and executes an inquiry statement for acquiring an inquiry result of the next page according to the inquiry condition, the paging parameter and the additional condition corresponding to the next page, and acquires the inquiry result of the next page; or the method comprises: receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page; responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and an additional condition corresponding to the next page, executing the query statement, and acquiring the query result of the next page; and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
Furthermore, the logic instructions in the memory 530 may be implemented in the form of software functional units and stored in a computer readable storage medium when the software functional units are sold or used as independent products. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The processor 510 in the electronic device provided in the embodiment of the present invention may call the logic instruction in the memory 530, and the implementation manner of the logic instruction is consistent with the implementation manner of the data paging query method provided in the present invention, and the same beneficial effects may be achieved, and details are not described here.
In another aspect, an embodiment of the present invention further provides a computer program product, where the computer program product includes a computer program stored on a non-transitory computer-readable storage medium, the computer program includes program instructions, and when the program instructions are executed by a computer, the computer is capable of executing the data paging query method provided by the above-mentioned method embodiments, where the method includes: acquiring additional conditions corresponding to the next page according to the query result of the current page; sending the page turning instruction and the additional condition corresponding to the next page to the server, so that the server responds to the page turning instruction, generates and executes an inquiry statement for acquiring an inquiry result of the next page according to the inquiry condition, the paging parameter and the additional condition corresponding to the next page, and acquires the inquiry result of the next page; or the method comprises: receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page; responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and an additional condition corresponding to the next page, executing the query statement, and acquiring the query result of the next page; and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
When executed, the computer program product provided in the embodiment of the present invention implements the data paging query method, and the specific implementation manner of the method is consistent with the implementation manner described in the embodiment of the foregoing method, and the same beneficial effects can be achieved, and details are not described here.
In another aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program is implemented by a processor to perform the data paging query method provided in the foregoing embodiments, and the method includes: acquiring additional conditions corresponding to the next page according to the query result of the current page; sending the page turning instruction and the additional condition corresponding to the next page to the server, so that the server responds to the page turning instruction, generates and executes an inquiry statement for acquiring an inquiry result of the next page according to the inquiry condition, the paging parameter and the additional condition corresponding to the next page, and acquires the inquiry result of the next page; or the method comprises: receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page; responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and an additional condition corresponding to the next page, executing the query statement, and acquiring the query result of the next page; and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
When the computer program stored on the non-transitory computer-readable storage medium provided in the embodiments of the present invention is executed, the data paging query method is implemented, and the specific implementation manner of the method is consistent with the implementation manner described in the embodiments of the method, and the same beneficial effects can be achieved, which is not described herein again.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. With this understanding in mind, the above-described technical solutions may be embodied in the form of a software product, which can be stored in a computer-readable storage medium such as ROM/RAM, magnetic disk, optical disk, etc., and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the methods described in the embodiments or some parts of the embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.
Claims (10)
1. A data paging query method is characterized by comprising the following steps:
acquiring additional conditions corresponding to the next page according to the query result of the current page;
and sending the page turning instruction and the additional condition corresponding to the next page to a server, so that the server responds to the page turning instruction, generates and executes a query statement for obtaining a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and obtains the query result of the next page.
2. The method for paging query of data according to claim 1, wherein after sending the page turning instruction and the additional condition corresponding to the next page to the server, the method further comprises:
and receiving the query result of the next page sent by the server.
3. The method for paging data inquiry according to claim 1 or 2, wherein the step of obtaining the additional condition corresponding to the next page according to the inquiry result of the current page comprises:
acquiring target parameters in the last line of data in the query result of the current page;
and acquiring the additional condition corresponding to the next page according to the target parameter in the last line of data in the query result of the current page.
4. The method for data paging query of claim 3, wherein the target parameters include a primary key and an index.
5. A data paging query method is characterized by comprising the following steps:
receiving a page turning instruction sent by a terminal and an additional condition corresponding to a next page;
responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, executing the query statement, and acquiring the query result of the next page;
and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
6. The method for paging data inquiry according to claim 5, wherein the generating and executing, in response to the page flipping command, an inquiry statement for obtaining an inquiry result of a next page according to an inquiry condition, a paging parameter, and an additional condition corresponding to the next page, and after obtaining the inquiry result of the next page, further includes:
and sending the query result of the next page to the terminal.
7. A data paging query apparatus, comprising:
the acquisition module is used for acquiring the additional condition corresponding to the next page according to the query result of the current page;
and the first communication module is used for sending the page turning instruction and the additional condition corresponding to the next page to a server, so that the server responds to the page turning instruction, generates and executes a query statement for obtaining a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, and obtains the query result of the next page.
8. A data paging query apparatus, comprising:
the second communication module is used for receiving a page turning instruction sent by the terminal and an additional condition corresponding to a next page;
the query module is used for responding to the page turning instruction, generating a query statement for acquiring a query result of the next page according to the query condition, the paging parameter and the additional condition corresponding to the next page, executing the query statement and acquiring the query result of the next page;
and acquiring the additional condition corresponding to the next page by the terminal according to the query result of the current page.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the data paging query method as claimed in any one of claims 1 to 6 when executing the program.
10. A non-transitory computer readable storage medium, on which a computer program is stored, wherein the computer program, when executed by a processor, implements the steps of the data paging query method according to any one of claims 1 to 6.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011460731.6A CN112416967B (en) | 2020-12-11 | 2020-12-11 | Data paging query method and device, electronic equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202011460731.6A CN112416967B (en) | 2020-12-11 | 2020-12-11 | Data paging query method and device, electronic equipment and storage medium |
Publications (2)
Publication Number | Publication Date |
---|---|
CN112416967A true CN112416967A (en) | 2021-02-26 |
CN112416967B CN112416967B (en) | 2024-05-14 |
Family
ID=74775642
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202011460731.6A Active CN112416967B (en) | 2020-12-11 | 2020-12-11 | Data paging query method and device, electronic equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN112416967B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113326302A (en) * | 2021-05-28 | 2021-08-31 | 网易(杭州)网络有限公司 | Data query method and device and storage medium |
CN115935090A (en) * | 2023-03-10 | 2023-04-07 | 北京锐服信科技有限公司 | Data query method and system based on time slicing |
Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020078047A1 (en) * | 2000-12-14 | 2002-06-20 | International Business Machines Corporation | Method, system, and program for reverse index scanning |
CN104281582A (en) * | 2013-07-02 | 2015-01-14 | 阿里巴巴集团控股有限公司 | Pagination display control method and device |
CN107045499A (en) * | 2016-02-05 | 2017-08-15 | 中兴通讯股份有限公司 | A kind of method and server for realizing data query |
CN109344197A (en) * | 2018-09-13 | 2019-02-15 | 广州帷策智能科技有限公司 | Paging method for down loading and device based on big data |
CN110555034A (en) * | 2018-03-28 | 2019-12-10 | 武汉斗鱼网络科技有限公司 | Data query paging method, device, server and medium |
-
2020
- 2020-12-11 CN CN202011460731.6A patent/CN112416967B/en active Active
Patent Citations (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20020078047A1 (en) * | 2000-12-14 | 2002-06-20 | International Business Machines Corporation | Method, system, and program for reverse index scanning |
CN104281582A (en) * | 2013-07-02 | 2015-01-14 | 阿里巴巴集团控股有限公司 | Pagination display control method and device |
CN107045499A (en) * | 2016-02-05 | 2017-08-15 | 中兴通讯股份有限公司 | A kind of method and server for realizing data query |
CN110555034A (en) * | 2018-03-28 | 2019-12-10 | 武汉斗鱼网络科技有限公司 | Data query paging method, device, server and medium |
CN109344197A (en) * | 2018-09-13 | 2019-02-15 | 广州帷策智能科技有限公司 | Paging method for down loading and device based on big data |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN113326302A (en) * | 2021-05-28 | 2021-08-31 | 网易(杭州)网络有限公司 | Data query method and device and storage medium |
CN115935090A (en) * | 2023-03-10 | 2023-04-07 | 北京锐服信科技有限公司 | Data query method and system based on time slicing |
Also Published As
Publication number | Publication date |
---|---|
CN112416967B (en) | 2024-05-14 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN103703467B (en) | Method and apparatus for storing data | |
TWI740029B (en) | Distributed search and index updating method, system, server and computer equipment | |
US9104676B2 (en) | Hash algorithm-based data storage method and system | |
CN108460041B (en) | Data processing method and device | |
CN109299157B (en) | Data export method and device for distributed big single table | |
CN112416967A (en) | Data paging query method and device, electronic equipment and storage medium | |
US20170170968A1 (en) | Method and apparatus for generating two-dimensional matrix, and method and apparatus for querying key value element | |
CN112800287B (en) | Full-text indexing method and system based on graph database | |
CN111885216B (en) | DNS query method, device, equipment and storage medium | |
US20150249719A1 (en) | Method and device for pushing information | |
CN109829073B (en) | Image searching method and device | |
CN108009250B (en) | Multi-classification event data cache establishing and querying method and device | |
CN114398371A (en) | Multi-copy fragmentation method, device, equipment and storage medium for database cluster system | |
CN112231398A (en) | Data storage method, device, equipment and storage medium | |
CN113992658A (en) | Data transmission method and related device, equipment, system and storage medium | |
CN110928900B (en) | Multi-table data query method, device, terminal and computer storage medium | |
CN105989007B (en) | File path processing method and device | |
CN112148925B (en) | User identification association query method, device, equipment and readable storage medium | |
CN113986931B (en) | Report paging method and device, storage medium and computing equipment | |
CN106446080B (en) | Data query method, query service equipment, client equipment and data system | |
CN107305581B (en) | Table connection method in distributed database system and distributed database system | |
CN113986948A (en) | Query method, device, server and storage medium of instant message | |
CN111966682A (en) | White list protection matching method, system, terminal and storage medium | |
CN112464045B (en) | Data processing method, device, equipment and storage medium | |
CN111767152B (en) | Method, apparatus and computer readable storage medium for detecting resource idling |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |