Paging query method and device, storage medium and electronic device
By determining the first data result from a preset number of databases in the database set and retrieving the data to be queried from the remaining databases in stages, the problem of high memory usage in database pagination queries is solved, thereby improving query efficiency and service availability.
Patent Information
- Application Number
- CN202110516746.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-12
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2041-05-12
AI Technical Summary
In database pagination queries, existing technologies cannot route data according to established rules, resulting in full database and full table scans, which increases memory usage and reduces query efficiency.
The first data result is determined from a preset number of databases in the database set, and the data to be queried is obtained from the remaining databases in stages. The data preparation and acquisition are carried out using structured query statements and unique identifiers, and the target data result is determined step by step.
It reduces the amount of data processed by the application server each time, avoids memory overflow, ensures high service availability, improves data acquisition efficiency, and saves data processing time.
Smart Images

Figure CN113239040B_ABST
Abstract
Description
Background Art
[0002] As the amount of data in the database increases dramatically, in order to alleviate the database bottleneck, it is necessary to disperse the data into different databases to improve database performance.
[0003] In the prior art, data in horizontally distributed libraries and tables is routed to specific libraries and tables according to certain rules, and directly related data is queried and returned to the caller for use.
[0004] However, if the actual business scenario does not meet the established rules, it will lead to full database and full table scan data, increasing memory usage and reducing query efficiency. Summary of the invention
[0005] The present disclosure provides a paging query method, a paging query device, a computer-readable storage medium and an electronic device, thereby overcoming the problems of high memory occupancy and low query efficiency at least to a certain extent.
[0006] According to a first aspect of the present disclosure, a paging query method is provided, comprising:
[0007] In response to the paging query request, the to-be-queried data of a preset number of databases are obtained from the database set;
[0008] Determining a first data result from the data to be queried in the preset number of databases;
[0009] Sending a data preparation request to the remaining databases in the database set, wherein the remaining databases are databases other than the preset number of databases in the database set;
[0010] Sending data requests to the remaining databases in batches to obtain the data to be queried in the remaining databases;
[0011] Determine a target data result according to the first data result and the remaining database data to be queried acquired in batches;
[0012] Determine the paging record of the target paging according to the target data result.
[0013] Optionally, determining the target data result according to the first data result and the remaining database data to be queried loaded in batches includes:
[0014] Acquire first to-be-queried data corresponding to the first database from the first set consisting of all the remaining databases;
[0015] Determine a second data result according to the first data result and the first data to be queried;
[0016] Acquire second to-be-queried data corresponding to a second database from a second set obtained after excluding the first database from the first set;
[0017] Determine a third data result according to the second data result and the second data to be queried;
[0018] The third data result is used as the first data result, and the first data to be queried is re-acquired from the third set obtained after excluding the second database from the second set to re-determine the third data result, until all the remaining databases are traversed, and the re-determined third data result is determined as the target data result.
[0019] Optionally, sending a data preparation request to remaining databases of the database set includes:
[0020] Generate a first structured query statement according to the query condition in the data preparation request;
[0021] Generate a corresponding unique identification code according to the first structured query statement;
[0022] The first structured query statement and the unique identification code are sent to the remaining databases.
[0023] Optionally, obtaining first to-be-queried data corresponding to the first database includes:
[0024] The unique identification code is sent to the first database again to obtain the first data to be queried.
[0025] Optionally, in response to a paging query request, obtaining a preset number of databases from a database set to be queried includes:
[0026] Generate a second structured query statement according to the query condition in the paging query request;
[0027] The second structured query statement is sent to the preset number database to obtain the data to be queried from the preset number database.
[0028] Optionally, determining the first data result from the data to be queried in the preset number database includes:
[0029] The data to be queried in the preset number of databases are sorted, and the first data result is determined from the sorted data to be queried in the preset number of databases according to the query condition.
[0030] Optionally, determining the second data result according to the first data result and the first data to be queried includes:
[0031] A position where the first data to be queried is to be inserted is determined in the first data result, and the first data to be queried is processed according to the position where the data to be queried is to be inserted, so as to determine the second data result.
[0032] Optionally, determining a position to be inserted of the first to-be-queried data in the first data result, and processing the first to-be-queried data according to the position to be inserted includes:
[0033] Extracting target data from the first data to be queried, and searching the position to be inserted from the first data result using a cursor;
[0034] Determine whether the position to be inserted is the last position in the first data result;
[0035] If yes, discard the target data;
[0036] If not, inserting the target data into the position to be inserted, and deleting the data corresponding to the last position in the first data result;
[0037] Until the cursor traverses all the data to be queried in the first database.
[0038] Optionally, obtaining the to-be-queried data of a preset number of databases from the database set includes:
[0039] According to a preset ratio, the to-be-queried data of the preset number of databases are acquired from the database set.
[0040] According to a second aspect of the present disclosure, a paging query device is provided, comprising:
[0041] A first data acquisition module is used to respond to a paging query request and acquire the to-be-queried data of a preset number of databases from a database set;
[0042] A first data result determination module, used to determine a first data result from the data to be queried in the preset number of databases;
[0043] A request sending module, used for sending a data preparation request to the remaining databases in the database set, wherein the remaining databases are databases other than the preset number of databases in the database set;
[0044] A second data acquisition module is used to send data requests to the remaining databases in batches to acquire the data to be queried in the remaining databases;
[0045] A target data result determination module, configured to determine a target data result according to the first data result and the remaining database data to be queried acquired in batches;
[0046] The paging record determination module is used to determine the paging record of the target paging according to the target data result.
[0047] According to a third aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned paging query method is implemented.
[0048] According to a fourth aspect of the present disclosure, there is provided an electronic device, including:
[0049] processor;
[0050] The memory is used to store one or more programs. When the one or more programs are executed by the processor, the processor implements the above-mentioned paging query method.
[0051] In the technical solutions provided by some embodiments of the present disclosure, on the one hand, by determining the first data result from the to-be-queried data of a preset number of databases in the database set, and then acquiring the to-be-queried data from the remaining databases in batches to determine the target data result, the amount of data processed by the application server each time can be reduced, the memory occupancy rate is reduced, the memory overflow is avoided, and the high availability of the service is ensured. On the other hand, by sending a data preparation request to the remaining databases so that the remaining databases can extract the to-be-queried data for query and preparation, the efficiency of later data acquisition is improved, and on the basis of saving memory, the time of data processing is saved, thereby achieving the purpose of improving efficiency.
[0052] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] The drawings herein are incorporated into the specification and constitute a part of the specification, showing embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:
[0054] Figure 1 A schematic diagram schematically illustrates an exemplary system architecture of a paging query solution according to an embodiment of the present disclosure;
[0055] Figure 2 A flowchart schematically shows a paging query method according to an exemplary embodiment of the present disclosure;
[0056] Figure 3 A schematic diagram of the structure of data query in the paging query method of an exemplary embodiment of the present disclosure is schematically shown;
[0057] Figure 4 A schematic diagram of a structure for acquiring to-be-queried data of a preset number of databases from a database set according to an exemplary embodiment of the present disclosure is schematically shown;
[0058] Figure 5 A schematic diagram schematically shows a structure of an application server sending a data preparation request to the remaining databases of a database set according to an exemplary embodiment of the present disclosure;
[0059] Figure 6 A schematic diagram showing a structure in which an application server sends a data request to the remaining databases of a database set according to an exemplary embodiment of the present disclosure;
[0060] Figure 7 A flowchart of an operation of obtaining target data results according to an exemplary embodiment of the present disclosure is schematically shown;
[0061] Figure 8 The following schematically shows an operation flow chart of determining a second data result based on a first data result and first data to be queried according to an exemplary embodiment of the present disclosure;
[0062] Fig. 9 A block diagram schematically shows a paging query device according to an exemplary embodiment of the present disclosure;
[0063] Fig.10 A schematic structural diagram of an electronic device according to an exemplary embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0064] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as being limited to the examples set forth herein; on the contrary, these embodiments are provided so that the present disclosure will be more comprehensive and complete, and the concepts of the example embodiments are fully conveyed to those skilled in the art. The described features, structures, or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known technical solutions are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0065] In addition, the accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and their repeated description will be omitted. Some of the block diagrams shown in the accompanying drawings are functional entities and do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or implemented in one or more hardware modules or integrated circuits, or implemented in different networks and / or processor devices and / or microcontroller devices.
[0066] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the steps. For example, some steps may be decomposed, while some steps may be combined or partially combined, so the actual execution order may change according to the actual situation. In addition, all the terms "first" and "second" below are only for the purpose of distinction and should not be used as limitations of the present disclosure.
[0067] With the rapid development of system business, the amount of data in the database has increased significantly, causing the performance of the database to decline. For relational databases that use relational models to organize data, the storage capacity, number of connections, and processing power of a single machine are limited, which can easily become a bottleneck of the system. When the amount of data in a single table reaches 10 million or 100 GB, due to the large number of query dimensions, the performance of operations such as adding slaves and optimizing indexes will still decline severely.
[0068] In order to reduce the overhead of adding, deleting, modifying and querying massive amounts of data, reduce the burden on the database and improve data processing capabilities, the original database and original data table with excessively large data volumes are usually split horizontally and stored in multiple databases and multiple data tables according to certain rules. Each database and data table can be placed on a different server, which is called sharding.
[0069] In the case of horizontal database and table sharding, when querying data by page, if the data cannot be queried according to the existing specified routing rules, it will lead to scanning data in the entire database and table, and loading data from various databases on the application server, resulting in multiple amounts of data being loaded into the memory of the application server for filtering, sorting, etc. This will inevitably increase the memory usage and lead to low query efficiency.
[0070] Based on this, a paging query method is provided in an exemplary embodiment of the present disclosure. Figure 1 A schematic diagram showing an exemplary system architecture of a paging query solution according to an embodiment of the present disclosure.
[0071] like Figure 1As shown, the system architecture includes client 1001, application server 1002 and database server 1003. Client 1001 is the user interface part of the application, responsible for the interaction between the user and the application, accepting the user's input request, and returning the result to the user in an appropriate form (such as graphics, reports, etc.). The software running on the client side is also called the presentation layer software.
[0072] The application server 1002 is used to store the business logic layer (also called the functional layer) software, which is the core of the application logic processing and the implementation of specific business. It can respond to the client 1001 request and complete business processing or complex calculations. If there is a database access task, the system application layer of the application server 1002 can send instructions to the database server 1003 according to the requirements of the client 1001. When the application logic becomes complex or a new application is added, a new application server 1002 can be added.
[0073] The database server 1003 is used to execute the instructions sent by the application server 1002 to complete data storage, access query and integrity constraints, etc. After the operation is completed, the operation result is returned to the client 1001 through the application server.
[0074] In actual applications, the application server 1002 and the database server 1003 may be located on the same host or on different hosts.
[0075] The various steps of the paging query method described below are applied to the application server 1002 , that is, the various steps of the paging query method are executed by the application server 1002 .
[0076] Figure 2 The flowchart of the paging query method according to an exemplary embodiment of the present disclosure is schematically shown. Figure 2 , the paging query method may include the following steps:
[0077] Step S210: In response to the paging query request, obtain the to-be-queried data of a preset number of databases from the database set.
[0078] In the exemplary embodiment of the present disclosure, the page query request is sent by the user to the application server 1002 through the client 1001. In response to the received page query request, the application server 1002 first determines a preset number of databases according to a preset ratio.
[0079] After determining the preset number of databases, refer to Figure 3In the paging query method provided by the exemplary embodiment of the present disclosure, the application server 1002 obtains the to-be-queried data of the preset number database 321 from the database set 320 of the database server 1003. That is, all the data of these preset number databases 321 are simultaneously loaded into the application server 1002 for data processing.
[0080] In actual applications, the size of the preset ratio can be determined according to the memory usage of the application server 1002. In order to ensure that the memory usage of the application server 1002 does not exceed the upper limit, the size of the preset ratio is less than 100%. In addition, if the preset ratio setting value is 0, step S210 can be ignored. In actual applications, the preset ratio is usually greater than or equal to 10%.
[0081] In actual application, the number n of the preset number of databases is determined by the preset ratio R and the total number N of databases in the database set of the database server 1003, that is, n=R*N. If the total number N of databases in the database set is 10, and the preset ratio R=30%, then the number n of the preset number of databases is 30%*10=3. Then, the application server 1002 will simultaneously obtain the data to be queried from the three databases.
[0082] In the exemplary embodiment of the present disclosure, referring to Figure 4 Specifically, obtaining the to-be-queried data of the preset number of databases from the database set includes: the application server 1002 generates a second structured query statement according to the query condition in the paging query request; and sends the second structured query statement as request data to each database 420 of the preset number of databases to obtain the to-be-queried data from each database 420 of the preset number of databases, and the preset number of databases returns all the obtained to-be-queried data to the application server 1002. Structured Query Language (SQL) is a special-purpose programming language, a database query and programming language, used to access data and query, update and manage relational database systems.
[0083] That is, step S210 is equivalent to simultaneously acquiring the to-be-queried data from a preset number of multiple databases, and according to a preset ratio, the amount of the acquired to-be-queried data is within the range of data that can be processed by the memory of the application server 1002 .
[0084] Step S220: Determine a first data result from the to-be-queried data in a preset number of databases.
[0085] After obtaining the to-be-queried data from a preset number of databases, the application server 1002 needs to determine a query result from the to-be-queried data as a first data result.
[0086] Taking the query business logic as time sorting query as an example, the application server 1002 needs to sort the acquired data to be queried in the preset number of databases, and then determine the first data result from the sorted data to be queried in the preset number of databases according to the query conditions.
[0087] If the business logic of the query is to query the first 1000 data by time sorting, then the application server 1002 will determine the first 1000 data from the sorted data to be queried as the first data result and temporarily store it.
[0088] Step S230: Send a data preparation request to the remaining databases in the database set, where the remaining databases are databases other than the preset number of databases in the database set.
[0089] In an exemplary embodiment of the present disclosure, after directly acquiring the data to be queried from a preset number of databases, the remaining databases other than the preset number of databases in the database set are acquired and processed one by one in batches.
[0090] First, while or after the application server 1002 sends a data request to a preset number of databases, such as Figure 3 As shown, a data preparation request is sent to each of the remaining databases 322 mentioned above, so that the remaining databases 322 are in the data preparation stage, so as to quickly obtain the data to be queried in the remaining databases 322 later.
[0091] In the exemplary embodiment of the present disclosure, referring to Figure 5 , the application server 1002 sends a data preparation request to the remaining databases 322 of the database set, including: generating a first structured query statement 510 according to the query conditions in the data preparation request; then generating a corresponding unique identifier (Universally Unique Identifier, UUID) 520 according to the first structured query statement 510; and finally sending the first structured query statement 510 and the unique identifier 520 as a data preparation request to each remaining database 322. Among them, the unique identifier 520 is unique in database identification and is a unique number that identifies the first structured query statement 510.
[0092] After receiving the first structured query statement 510 and the unique identification code 520, the remaining database 322 located on the database server 1003 will perform a query according to the first structured query statement 510, and match the queried data with the unique identification code 520 one by one for use in the next step.
[0093] Secondly, after determining the first data result, the application server 1002 will enter step S240 to send data requests to the remaining databases in batches to obtain the data to be queried in the remaining databases.
[0094] In the exemplary embodiment of the present disclosure, referring to Figure 6 After the first data result is determined and the remaining databases 322 have queried the data, the application server 1002 will send a data request to one of the remaining databases 322 at a time and obtain the data to be queried in the remaining database 322.
[0095] Then, if Figure 3 As shown, the application server 1002 processes the first data result and the data to be queried of the remaining database 322 to obtain a second data result; then, the application server 1002 obtains the data to be queried of the next remaining database 322, and obtains the data to be queried of the remaining databases 322 in batches until all the remaining databases 322 are traversed.
[0096] In an exemplary embodiment of the present disclosure, in the process of obtaining the data to be queried from the remaining database 322 , the application server 1002 may only send the previously generated unique identification code 520 as a data request to the remaining database 322 to obtain the data to be queried from the remaining database 322 .
[0097] In an exemplary embodiment of the present disclosure, after obtaining the first data result, the application server 1002 obtains and processes the data to be queried in the remaining databases in batches, that is, after processing the data to be queried in the previous remaining database, it obtains and processes the data to be queried in the next remaining database, until all the data to be queried in the remaining databases are processed.
[0098] Here, the determination of the target data result according to the first data result and the remaining database to-be-queried data acquired in batches in step S250 is described in detail:
[0099] In the exemplary embodiment of the present disclosure, referring to Figure 7 , shows an operation flow chart of obtaining target data results, such as Figure 7As shown, in step S710, a first data result is obtained from a preset number of databases 7002 in the database set 7001; then, step S720 is entered to obtain first data to be queried corresponding to the first database from a first set consisting of all remaining databases in the database set 7001, that is, to obtain the first data to be queried, wherein the first database is any database in the first set; then, step S730 is entered to determine a second data result based on the first data result and the first data to be queried; step S740 is entered to obtain second data to be queried corresponding to the second database from a second set obtained after excluding the first database from the first set. , that is, obtaining the second data to be queried, wherein the second database is any database in the second set; entering step S750, determining the third data result according to the second data result and the second data to be queried; after obtaining the third data result, re-entering step S710, taking the third data result as the first data result, re-obtaining the first data to be queried from the third set obtained after excluding the second database from the second set, and executing steps S720-S750 again to re-determine the third data result, and repeating this cycle until all the remaining databases have been traversed, and the re-determined third data result is determined as the target data result 7003.
[0100] It should be noted that, in the process of executing step S720 to step S750 again, the first data to be queried obtained is data from any database of the remaining databases excluding the first database and the second database. In other words, the first data to be queried and the second data to be queried obtained each time are obtained from the remaining databases that have not been obtained before, so that the data of all the remaining databases are traversed.
[0101] In the exemplary embodiment of the present disclosure, referring to Figure 8The above-mentioned determination of the second data result based on the first data result and the first data to be queried may specifically include: step S810, determining the position to be inserted of the first data to be queried in the first data result, that is, determining the position to be inserted, wherein a cursor may be used to search for the position to be inserted from the first data result; then, processing the first data to be queried according to the position to be inserted to determine the second data result. Among them, processing the first data to be queried according to the position to be inserted can specifically include: step S820, extracting target data from the first data to be queried, wherein the target data can be the first data in the first data to be queried, or any data in the first data to be queried; step S830, entering judgment condition 1, that is, judging whether the position to be inserted is the last position in the first data result; if yes, entering step S840, discarding the target data; if not, entering step S850, inserting the target data into the position to be inserted, and deleting the data corresponding to the last position in the first data result, referred to as inserting the target data; after completing step S840 or step S850, step S860 follows, entering judgment condition 2, that is, judging whether the data in the first data to be queried is traversed; if not, turning to step S810, obtaining the next target data, and then confirming the insertion position of the target data, until the cursor traverses all the first data to be queried in the first database, that is, if yes, entering step S870, determining the second data result.
[0102] It can be seen from the process shown in the above steps S810 to S870 that in the process of determining the second data result, by discarding the target data, or deleting the data corresponding to the last position in the first data result, the amount of data in the memory of the application server 1002 is always kept unchanged, for example, the above-mentioned 1000 data remain unchanged, thereby avoiding the occurrence of a surge in data in the memory, minimizing the memory occupancy rate, and improving the efficiency of data query processing.
[0103] In the exemplary embodiment of the present disclosure, the process of determining the third data result according to the second data result and the second to-be-queried data is as follows: Figure 8 The step of determining the second data result based on the first data result and the first data to be queried can be executed and will not be repeated here.
[0104] Step S260, determining the paging record of the target paging according to the target data result.
[0105] The data table corresponding to the target paging records is the data table containing the target paging records. Generally speaking, each database, each data table, and each record in the data table corresponds to a number. When displaying query results in pages, the query records are not displayed in a random order, but in the order of the numbers corresponding to the records. Therefore, query records from the same data table are arranged continuously when displayed in pages.
[0106] The target data result determined above is equivalent to the total data set sorted by page. Then, you can traverse the paging accordingly according to the number of pages that need to be displayed in the query. If there are 1000 data in the total data set, and 100 data are displayed on each page, if you want to display the data on page 10, you can intercept the 901st to 1000th data in the total data set as paging records for display.
[0107] In summary, based on the paging query method of the exemplary embodiment of the present disclosure, on the one hand, by determining the first data result from the data to be queried in a preset number of databases of the database set, and then obtaining the data to be queried from the remaining databases in batches to determine the target data result, the amount of data processed by the application server each time can be reduced, the memory occupancy rate is reduced, the memory overflow is avoided, and the high availability of the service is ensured. On the other hand, by sending a data preparation request to the remaining databases so that the remaining databases can extract the data to be queried for query and preparation, the efficiency of later data acquisition is improved, and on the basis of saving memory, the time for data processing is saved, thereby achieving the purpose of improving efficiency. On the other hand, in the process of determining the second data result, by discarding the target data, or deleting the data corresponding to the last position in the first data result, the amount of data in the application server memory is always kept unchanged, thereby avoiding the situation of a surge in data in the memory, minimizing the memory occupancy rate, and further improving the efficiency of data query processing.
[0108] Furthermore, a paging query device is also provided in an exemplary embodiment of the present disclosure.
[0109] Fig. 9 The block diagram of the paging query device according to the exemplary embodiment of the present disclosure is schematically shown. Fig. 9 According to an exemplary embodiment of the present disclosure, a paging query device 900 may include a first data acquisition module 910, a first data result determination module 920, a request sending module 930, a second data acquisition module 940, a target data result determination module 950 and a paging record determination module 960.
[0110] Specifically, the first data acquisition module 910 may be used to respond to a paging query request and acquire to-be-queried data of a preset number of databases from a database set;
[0111] The first data result determination module 920 may be used to determine the first data result from the to-be-queried data in the preset number of databases;
[0112] The request sending module 930 may be used to send a data preparation request to the remaining databases in the database set, where the remaining databases are databases other than the preset number of databases in the database set;
[0113] The second data acquisition module 940 may be used to send data requests to the remaining databases in batches to acquire the data to be queried in the remaining databases;
[0114] The target data result determination module 950 may be used to determine the target data result according to the first data result and the remaining database data to be queried acquired in batches;
[0115] The paging record determination module 960 may be used to determine the paging records of the target paging according to the target data result.
[0116] Since the functional modules of the paging query device according to the exemplary embodiment of the present disclosure are the same as those in the above method implementation, they will not be described in detail here.
[0117] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0118] In an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0119] It will be appreciated by those skilled in the art that various aspects of the present invention may be implemented as a system, method or program product. Therefore, various aspects of the present invention may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to herein as a "circuit", "module" or "system".
[0120] Refer to the following Fig.10 The electronic device 1000 according to this embodiment of the present invention will be described. Fig.10 The electronic device 1000 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0121] like Fig.10As shown, the electronic device 1000 is in the form of a general computing device. The components of the electronic device 1000 may include but are not limited to: the at least one processing unit 1010, the at least one storage unit 1020, a bus 1030 connecting different system components (including the storage unit 1020 and the processing unit 1010), and a display unit 1040.
[0122] The storage unit 1020 stores program codes, which can be executed by the processing unit 1010, so that the processing unit 1010 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Method” section of this specification. For example, the processing unit 1010 can perform the following steps: Figure 2 In the step S210 shown in the figure, in response to the paging query request, the data to be queried of a preset number of databases are obtained from the database set; in step S220, a first data result is determined from the data to be queried of the preset number of databases; in step S230, a data preparation request is sent to the remaining databases of the database set, and the remaining databases are databases other than the preset number of databases in the database set; in step S240, data requests are sent to the remaining databases in batches to obtain the data to be queried of the remaining databases; in step S250, a target data result is determined based on the first data result and the data to be queried of the remaining databases obtained in batches; in step S260, a paging record of a target paging is determined based on the target data result.
[0123] The storage unit 1020 may include a readable medium in the form of a volatile storage unit, such as a random access storage unit (RAM) 10201 and / or a cache storage unit 10202 , and may further include a read-only storage unit (ROM) 10203 .
[0124] The storage unit 1020 may also include a program / utility 10204 having a set (at least one) of program modules 10205, such program modules 10205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0125] Bus 1030 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0126] The electronic device 1000 may also communicate with one or more external devices 1070 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 1000, and / or communicate with any device that enables the electronic device 1000 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 1050. Furthermore, the electronic device 1000 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 1060. As shown, the network adapter 1060 communicates with other modules of the electronic device 1000 via a bus 1030. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 1000, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0127] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0128] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is also provided, on which a program product capable of implementing the above method of the present specification is stored. In some possible implementations, various aspects of the present invention can also be implemented in the form of a program product, which includes a program code, and when the program product is run on a terminal device, the program code is used to enable the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the above "Exemplary Method" section of the present specification.
[0129] The program product for implementing the above method according to an embodiment of the present invention may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0130] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0131] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0132] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0133] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0134] In addition, the above-mentioned figures are only schematic illustrations of the processes included in the method according to an exemplary embodiment of the present invention, and are not intended to be limiting. It is easy to understand that the processes shown in the above-mentioned figures do not indicate or limit the time sequence of these processes. In addition, it is also easy to understand that these processes can be performed synchronously or asynchronously, for example, in multiple modules.
[0135] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing what is disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and embodiments are to be considered merely as exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.
[0136] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A paging query method, characterized in that: include: In response to the paging query request, the to-be-queried data of a preset number of databases are obtained from the database set; Determining a first data result from the data to be queried in the preset number of databases; Sending a data preparation request to the remaining databases in the database set, wherein the remaining databases are databases other than the preset number of databases in the database set; Sending data requests to the remaining databases in batches to obtain the data to be queried in the remaining databases; Determine a target data result according to the first data result and the remaining database data to be queried acquired in batches; Determine the paging record of the target paging according to the target data result; The step of determining the target data result according to the first data result and the remaining database data to be queried obtained in batches includes: Acquire first to-be-queried data corresponding to the first database from the first set consisting of all the remaining databases; Determine a second data result according to the first data result and the first data to be queried; Acquire second to-be-queried data corresponding to a second database from a second set obtained after excluding the first database from the first set; Determine a third data result according to the second data result and the second data to be queried; The third data result is used as the first data result, and the first data to be queried is re-acquired from the third set obtained after excluding the second database from the second set to re-determine the third data result, until all the remaining databases are traversed, and the re-determined third data result is determined as the target data result.
2. The paging query method according to claim 1, characterized in that: Sending a data preparation request to the remaining databases of the database set includes: Generate a first structured query statement according to the query condition in the data preparation request; Generate a corresponding unique identification code according to the first structured query statement; The first structured query statement and the unique identification code are sent to the remaining databases.
3. The paging query method according to claim 2, characterized in that: Acquiring first to-be-queried data corresponding to the first database includes: The unique identification code is sent to the first database again to obtain the first data to be queried.
4. The paging query method according to claim 1, characterized in that: In response to the paging query request, the data to be queried of a preset number of databases is obtained from the database set, including: Generate a second structured query statement according to the query condition in the paging query request; The second structured query statement is sent to the preset number database to obtain the data to be queried from the preset number database.
5. The paging query method according to claim 1, characterized in that: Determining the first data result from the to-be-queried data in the preset number of databases includes: The data to be queried in the preset number of databases are sorted, and the first data result is determined from the sorted data to be queried in the preset number of databases according to the query condition.
6. The paging query method according to claim 5, characterized in that: Determining a second data result according to the first data result and the first data to be queried includes: A position where the first data to be queried is to be inserted is determined in the first data result, and the first data to be queried is processed according to the position where the data to be queried is to be inserted, so as to determine the second data result.
7. The paging query method according to claim 5, characterized in that: Determining a position to be inserted of the first to-be-queried data in the first data result, and processing the first to-be-queried data according to the position to be inserted includes: Extracting target data from the first data to be queried, and searching the position to be inserted from the first data result using a cursor; Determine whether the position to be inserted is the last position in the first data result; If yes, discard the target data; If not, inserting the target data into the position to be inserted, and deleting the data corresponding to the last position in the first data result; Until the cursor traverses all the data to be queried in the first database.
8. The paging query method according to any one of claims 1 to 7, characterized in that: The data to be queried for obtaining a preset number of databases from the database set includes: According to a preset ratio, the to-be-queried data of the preset number of databases are acquired from the database set.
9. A paging query device, characterized in that: include: A first data acquisition module is used to respond to a paging query request and acquire the to-be-queried data of a preset number of databases from a database set; A first data result determination module, used to determine a first data result from the data to be queried in the preset number of databases; A request sending module, used for sending a data preparation request to the remaining databases in the database set, wherein the remaining databases are databases other than the preset number of databases in the database set; A second data acquisition module is used to send data requests to the remaining databases in batches to acquire the data to be queried in the remaining databases; A target data result determination module, configured to determine a target data result according to the first data result and the remaining database data to be queried acquired in batches; A paging record determination module, used to determine the paging record of the target paging according to the target data result; The step of determining the target data result according to the first data result and the remaining database data to be queried obtained in batches includes: Acquire first to-be-queried data corresponding to the first database from the first set consisting of all the remaining databases; Determine a second data result according to the first data result and the first data to be queried; Acquire second to-be-queried data corresponding to a second database from a second set obtained after excluding the first database from the first set; Determine a third data result according to the second data result and the second data to be queried; The third data result is used as the first data result, and the first data to be queried is re-acquired from the third set obtained after excluding the second database from the second set to re-determine the third data result, until all the remaining databases are traversed, and the re-determined third data result is determined as the target data result.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the paging query method according to any one of claims 1 to 8 is implemented.
11. An electronic device, characterized in that: include: processor; A memory for storing one or more programs, which, when executed by the processor, enables the processor to implement the paging query method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Data processing method and device, electronic equipment and computer readable storage medium
CN111367948A
Paging query method and device, electronic equipment and computer readable storage medium
CN112527824A