Multi-table paging query method, device, equipment and storage medium

文档序号:7576 发布日期:2021-09-17 浏览:41次 中文

1. A multi-table paging query method is applied to a client, and is characterized by comprising the following steps:

if receiving the first input, sending a first query request to the server; the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value;

receiving and analyzing a first query result sent by the server, and updating a query parameter into a second query parameter based on the first query result; the first query result is obtained by the server-side performing paging query on the first data table;

if receiving a second input, sending a second query request to the server so that the server queries a target data table according to the second query parameter; the second query request includes the second query parameter, and the target data table is one of the plurality of data tables.

2. The method of claim 1, wherein updating the first query parameter to a second query parameter based on the first query result comprises:

and updating the query parameter to be a second query parameter based on the target data volume and the data volume in the first query result.

3. The method of claim 2, wherein updating the query parameter to the second query parameter based on the target amount of data and the amount of data in the first query result comprises:

if the data quantity in the first query result is equal to the target data quantity, updating the query page value to be a second page value;

and the second page value is the sum of 1 of the first page value, and the second query request is used for requesting to return a second query result of the first data table.

4. The method of claim 2, wherein updating the query parameter to the second query parameter based on the target amount of data and the amount of data in the first query result comprises:

if the data quantity in the first query result is smaller than the target data quantity, updating the sub-table parameter value to be a second sub-table parameter value, and resetting the query page value to be the first page value;

the second sub-table parameter value is a sub-table parameter value adjacent to the first sub-table parameter value, the second sub-table parameter value corresponds to a second sub-table in the plurality of sub-tables, and the second query request is used for requesting to return a query result of the second sub-table.

5. The method of claim 4, further comprising:

and if the updated sub-table parameter value is smaller than the minimum sub-table parameter value or larger than the maximum sub-table parameter value, outputting prompt information after receiving query input, wherein the prompt information indicates that the query is terminated.

6. The method according to any one of claims 1 to 5,

the sub-table parameters are day, week, month, quarter or year; alternatively, the first and second electrodes may be,

the sub-table parameter is the last numerical value of the user identifier; alternatively, the first and second electrodes may be,

the sub-table parameter is a numerical value obtained by performing hash operation and modulo operation on the character string of the user identifier.

7. A multi-table paging query method is applied to a server side, and is characterized by comprising the following steps:

receiving a first query request sent by a client, wherein the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value;

acquiring a first data table according to the first table parameter value;

performing paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table, and sending the first query result to the client;

and under the condition of receiving a second query request sent by the client, paging a target data table according to a second query parameter, wherein the second query request comprises the second query parameter, the second query parameter is a query parameter updated by the client according to a first query result, and the target data table is one of the multiple data tables.

8. The method of claim 7, wherein paging the target data table according to the second lookup parameter comprises:

if the value of the sub-table parameter in the second query parameter is a first sub-table parameter value, the value of the query page is a second page value, and the data volume of each page is the target data volume, acquiring a second query result of the first data table according to the target data volume;

wherein the amount of data in the first query result is equal to the target amount of data.

9. The method of claim 7, wherein paging the target data table according to the second lookup parameter comprises:

if the value of the sub-table parameter in the second query parameter is a second sub-table parameter value, the value of the query page is the first page value, and the data volume of each page is a target data volume, performing paging query on a second data table in the plurality of data tables according to the second sub-table parameter value;

and the data volume in the first query result is smaller than the target data volume, and the second sub-table parameter value corresponds to the second data table.

10. The method according to any one of claims 7 to 9,

the sub-table parameters are day, week, month, quarter or year; alternatively, the first and second electrodes may be,

the sub-table parameter is the last numerical value of the user identifier; alternatively, the first and second electrodes may be,

the sub-table parameter is a numerical value obtained by performing hash operation and modulo operation on the character string of the user identifier.

11. A multi-table paging query device, comprising: the device comprises a sending module, a receiving module, an analyzing module and an updating module;

the sending module is used for sending a first query request if receiving a first input; the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value;

the receiving module is used for receiving a first query result sent by the server; the first query result is obtained by the server-side performing paging query on a first data table;

the analysis module is used for analyzing the first query result received by the receiving module;

the updating module is used for updating the query parameter into a second query parameter based on the first query result analyzed by the analyzing module;

the sending module is further configured to send a second query request to the server if a second input is received, so that the server queries the target data table according to the second query parameter; the second query request includes the second query parameter, and the target data table is one of the plurality of data tables.

12. A multi-table paging query device, comprising: the system comprises a receiving module, an obtaining module, a query module and a sending module;

the receiving module is used for receiving a first query request sent by a client, the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value;

the acquisition module is used for acquiring a first data table according to the first sub-table parameter value;

the query module is used for performing paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table;

the sending module is used for sending the first query result to the client;

the query module is further configured to query a target data table in a paging manner according to a second query parameter when receiving a second query request sent by the client, where the second query request includes the second query parameter, the second query parameter is a query parameter updated by the client according to a first query result, and the target data table is one of the multiple data tables.

13. A client comprising a processor, a memory, and a program or instructions stored on the memory and executable on the processor, the program or instructions when executed by the processor implementing the steps of the multi-table paging query method of any of claims 1 to 6.

14. A server comprising a processor, a memory, and a program or instructions stored on the memory and executable on the processor, the program or instructions when executed by the processor implementing the steps of the multi-table paging query method as claimed in any one of claims 7 to 10.

15. A readable storage medium, storing thereon a program or instructions which, when executed by a processor, implement the steps of the multi-table paging query method of any of claims 1 to 6, or 7 to 10.

Background

With the gradual expansion of internet services and the sharp increase of data volume, single-table storage cannot meet service requirements, and one data table needs to be split into a plurality of data tables. For example, one order table may be split into a plurality of data tables by month.

Generally, if a multi-table paging query is required, firstly, a service server calculates the total number of records of each sub-table; then, the service server side calculates which sub-tables have the requested records according to the request parameters sent by the client side; and finally, the service server side inquires data from the sub-tables and returns the data to the client side.

However, in the above multi-table paging query method, the calculation logic of the server is complex, a single query request of the client may require the server to query a plurality of tables, the server needs to calculate the offset of each table, and the database also needs to receive paging query of each table, which results in poor paging query performance.

Disclosure of Invention

The embodiment of the disclosure aims to provide a multi-table paging query method, device, equipment and storage medium, which can solve the problem of poor paging query performance.

In order to solve the technical problem, the present disclosure is implemented as follows:

in a first aspect, an embodiment of the present disclosure provides a multi-table paging query method, applied to a client, where the method includes: if receiving the first input, sending a first query request to the server; the first query request comprises a first query parameter, the value of the table parameter in the first query parameter is a first table parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; receiving and analyzing a first query result sent by a server, and updating a query parameter into a second query parameter based on the first query result; the first query result is obtained by the server side performing paging query on the first data table; if receiving a second input, sending a second query request to the server so that the server queries the target data table according to the second query parameter; the second query request includes a second query parameter, and the target data table is one of the plurality of data tables.

In a second aspect, an embodiment of the present disclosure provides a multi-table paging query apparatus, including: the device comprises a sending module, a receiving module, an analyzing module and an updating module; the sending module is used for sending a first query request if receiving a first input; the first query request includes a first query parameter; the value of the table dividing parameter in the first query parameter is a first table dividing parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; the receiving module is used for receiving a first query result sent by the server; the first query result is obtained by the server side performing paging query on the first data table; the analysis module is used for analyzing the first query result received by the receiving module; the updating module is used for updating the query parameter into a second query parameter based on the first query result analyzed by the analyzing module; the sending module is further used for sending a second query request to the server side if receiving a second input, so that the server side queries the target data table according to the second query parameter; the second query request includes a second query parameter, and the target data table is one of the plurality of data tables.

In a third aspect, the embodiments of the present disclosure provide a client, which includes a processor, a memory, and a program or instructions stored on the memory and executable on the processor, and when executed by the processor, the program or instructions implement the steps of the method according to the first aspect.

In the embodiment of the disclosure, firstly, if a first input is received, a client sends a first query request to a server; the first query request includes a first query parameter. The value of the table dividing parameter in the first query parameter is a first table dividing parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume. Secondly, the client receives and analyzes the first query structure sent by the server, and then updates the query parameters into second query parameters according to the first query result. And if the second input is received, the client sends a second query request to the server so that the server queries the target data table according to the second query parameter. Because the first query parameter comprises the value of the sub-table parameter, the value of the query page and the data amount of each page, and the first sub-table parameter value corresponds to the first data table in the multiple data tables, the server can firstly search the first data table in the data tables split according to the value of the sub-table parameter according to the first sub-table parameter value in the query parameter, and then perform paging query on the first data table according to the value of the query page and the data amount of each page. The first query result is obtained by the server side performing paging query on the first data table; the client updates the next query parameter according to the last query result, so that the server only performs paging query on one data table at a time, namely, the original multi-table paging query is reduced to single-table paging query according to the sub-table parameters by improving the query parameter of the client, the complexity of a query system is reduced, the performance of the server is improved, and higher concurrent query quantity can be supported.

In a fourth aspect, an embodiment of the present disclosure provides a table paging query method, applied to a server, where the method includes: receiving a first query request sent by a client, wherein the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; acquiring a first data table according to the first table parameter value; performing paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table, and sending the first query result to the client; and under the condition of receiving a second query request sent by the client, paging and querying the target data table according to a second query parameter, wherein the second query request comprises the second query parameter, the second query parameter is a query parameter updated by the client according to the first query result, and the target data table is one of the multiple data tables.

In a fifth aspect, an embodiment of the present disclosure provides a multi-table paging query apparatus, including: the system comprises a receiving module, an obtaining module, a query module and a sending module; the receiving module is used for receiving a first query request sent by a client, wherein the first query request comprises a first query parameter, the value of a table parameter in the first query parameter is a first table parameter value, the value of a query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; the acquisition module is used for acquiring a first data table according to the first sub-table parameter value; the query module is used for performing paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table; the sending module is used for sending the first query result to the client; the query module is further configured to query the target data table in a paging manner according to the second query parameter when receiving a second query request sent by the client, where the second query request includes the second query parameter, the second query parameter is a query parameter updated by the client according to the first query result, and the target data table is one of the multiple data tables.

In a sixth aspect, the present disclosure provides a server, which includes a processor, a memory, and a program or an instruction stored in the memory and executable on the processor, and when executed by the processor, the program or the instruction implements the steps of the method according to the fourth aspect.

In the embodiment of the present disclosure, first, a server receives a first query request sent by a client, where the first query request includes a first query parameter, a value of a table parameter in the first query parameter is a first table parameter value, a value of a query page is a first page value, and a data amount of each page is a target data amount. Then, the server side can acquire a first data table corresponding to a first sub-table parameter value from a plurality of data tables split according to the sub-table parameter value; then, the server side can perform paging query on the first data table according to the first page value and the target data volume in the first query parameter to obtain a first query result of the first data table, and sends the first query result to the client side; and under the condition of receiving a second query request sent by the client, the server searches the target data table in a paging mode according to the second query parameter. Because the query parameters comprise the first sub-table parameter values, the server can directly determine the corresponding data table according to the sub-table parameter values, only the data table corresponding to the sub-table parameter values is subjected to paging query in one query process, and cross-table query is not required, so that the implementation logic of the server is simplified, the access times of the data table are reduced, the complexity of a query system is reduced, the performances of the server and a database are improved, and a foundation is provided for supporting higher concurrent query quantity.

In a seventh aspect, the disclosed embodiments provide a readable storage medium, on which a program or instructions are stored, which when executed by a processor implement the steps of the method according to the first or fourth aspect.

In an eighth aspect, the present disclosure provides a chip, where the chip includes a processor and a communication interface, where the communication interface is coupled to the processor, and the processor is configured to execute a program or instructions to implement the method according to the first aspect or the fourth aspect.

Drawings

Fig. 1 is a schematic diagram of an architecture of a multi-table paging query system according to an embodiment of the present disclosure;

FIG. 2 is a flowchart illustrating a multi-table paging query method according to an embodiment of the present disclosure;

FIG. 3 is a second flowchart illustrating a multi-table paging query method according to an embodiment of the present disclosure;

fig. 4 is an interaction flow diagram of a multi-table paging query method according to an embodiment of the present disclosure;

FIG. 5 is a schematic diagram illustrating one possible structure of a multi-table paging query device according to an embodiment of the present disclosure;

FIG. 6 is a schematic diagram illustrating one possible structure of a multi-table paging query device according to an embodiment of the present disclosure;

fig. 7 is a second schematic diagram of a possible structure of the client according to the embodiment of the disclosure;

fig. 8 is a second schematic structural diagram of a server according to a second embodiment of the disclosure;

fig. 9 is a hardware schematic diagram of a client according to an embodiment of the present disclosure;

fig. 10 is a hardware schematic diagram of a server according to an embodiment of the present disclosure.

Detailed Description

The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the drawings in the embodiments of the present disclosure, and it is obvious that the described embodiments are some, but not all embodiments of the present disclosure. All other embodiments, which can be derived by a person skilled in the art from the embodiments disclosed herein without making any creative effort, shall fall within the protection scope of the present disclosure.

The terms first, second and the like in the description and in the claims of the present disclosure are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that embodiments of the disclosure may be practiced other than those illustrated or described herein, and that the objects identified as "first," "second," etc. are generally a class of objects and do not limit the number of objects, e.g., a first object may be one or more. In addition, "and/or" in the specification and claims means at least one of connected objects, a character "/" generally means that a preceding and succeeding related objects are in an "or" relationship.

The multi-table paging query method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings through specific embodiments and application scenarios thereof.

Fig. 1 is a schematic diagram of an architecture of a multi-table paging query system according to an embodiment of the present disclosure, as shown in fig. 1, the multi-table paging query system includes a client 101 and a server 102. The client 101 is configured to receive a query input from a user, initialize or update a query parameter according to the query input from the user, and send the query parameter to the server 102. The server 102 first obtains a data table corresponding to the sub-table parameter value according to the query parameter sent by the client 101, and then performs sub-table query on the data table according to the value of the query page and the target data volume.

Fig. 2 is a schematic flowchart of a multi-table paging query method according to an embodiment of the disclosure, as shown in fig. 2, the method includes the following steps S201 to S203:

s201, if the first input is received, the client sends a first query request to the server.

Wherein the first query request includes a first query parameter. The value of the table dividing parameter in the first query parameter is a first table dividing parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume. The first sub-table parameter value corresponds to a first data table of a plurality of data tables, and the data tables are data tables split according to the sub-table parameter value. The amount of data per page may be the number of pieces of data displayed per page.

Illustratively, the sub-table parameters may be: day, week, month, quarter, or year.

For example, for one order table, orders may be stored by month, and orders for one year may be stored in 12 data tables for 12 month shares, respectively.

For example, the sub-table parameter may be the last digit value of the user ID.

For example, the last digit of the user ID may be used to store the user-related data, and the user-related data may be stored in 10 data tables (the last digit is 0 to 9, and corresponds to one data table).

For example, the sub-table parameter may be a value obtained by performing a hash operation on a character string of the user ID and performing a modulo operation.

For example, a hash value may be obtained by performing a hash operation on a character string of the user ID, and then modulo the hash value by 32, any number of 0 to 31 may be obtained, and the user data may be stored in 32 data tables according to the obtained 0 to 31.

Illustratively, the first input is an input by a user that triggers the client to retrieve data.

Illustratively, after the client receives the user's query input, the client may initialize the query parameters. That is, if the client receives the first input, the client may initialize the query parameter as the first query parameter.

It should be noted that, in the embodiment of the present disclosure, the sub-table parameter in the initialized query parameter may be a default, or may be selected by the user from a plurality of sub-table parameters as needed, and this is not specifically limited in the embodiment of the present disclosure.

It should be noted that, when initializing the sub-table parameter values, the client may request the server to return the parameter range of the sub-table parameter values.

The first sub-table parameter value may default to a maximum value in the sub-table parameter values, may also default to a minimum value in the sub-table parameter values, and may also be an initial value selected by the user.

Optionally, the value of the target data amount may be a default value in the service, or may also be a value manually set according to the user, which is not specifically limited in this disclosure.

Illustratively, 20 pieces of data can be loaded at a time in one page, and 10 pieces of data can be loaded at a time.

S202, the client receives and analyzes the first query result sent by the server, and updates the query parameter into a second query parameter according to the first query result.

The first query result is obtained by the server side performing paging query on the first data table.

It is to be understood that the client may update at least one of a value of a table-splitting parameter and a value of a query page in the query parameter according to the first query result.

It is to be understood that the first table parameter value in the first query parameter may instruct the server to query the data in the first data table.

It should be noted that, after receiving the first query result returned by the server, the client updates the query parameter, so that the next query can request the server to perform a query based on the updated query parameter.

S203, if the second input is received, the client sends a second query request to the server, so that the server queries the target data table according to the second query parameter.

The second query request comprises a second query parameter, and the target data table is one of the data tables.

It should be noted that the second input may be an input that the user triggers the client to continue loading data, for example, the second input is an input that the user pulls down a refresh page on the interface.

In the embodiment of the present disclosure, the target data table may be the first data table, and may also be a data table adjacent to the first data table.

It is to be appreciated that the client, upon detecting the second input by the user, may request the server to query the database for data according to the second query parameter that was previously updated.

Illustratively, taking the sub-table parameter as the month as an example, the query parameter carries month information, so that the server query logic can be simplified into a paging query in a single table. The client only needs to request to acquire a queryable range during initialization, query parameters are dynamically adjusted through query results, a request is sent to the server one by one to load new paging data, and the server traverses the data table corresponding to each month in sequence during paging query, so that data paging query according to the time paging is realized.

The multi-table paging query method provided by the embodiment of the disclosure includes that firstly, if a first input is received, a client sends a first query request to a server; the first query request includes a first query parameter. The value of the table dividing parameter in the first query parameter is a first table dividing parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume. Secondly, the client receives and analyzes the first query structure sent by the server, and then updates the query parameters into second query parameters according to the first query result. And if the second input is received, the client sends a second query request to the server so that the server queries the target data table according to the second query parameter. Because the first query parameter comprises the value of the sub-table parameter, the value of the query page and the data amount of each page, and the first sub-table parameter value corresponds to the first data table in the multiple data tables, the server can firstly search the first data table in the data tables split according to the value of the sub-table parameter according to the first sub-table parameter value in the query parameter, and then perform paging query on the first data table according to the value of the query page and the data amount of each page. The first query result is obtained by the server side performing paging query on the first data table; the client updates the next query parameter according to the last query result, so that the server only performs paging query on one data table at a time, namely, the original multi-table paging query is reduced to single-table paging query according to the sub-table parameters by improving the query parameter of the client, the complexity of a query system is reduced, the performance of the server is improved, and higher concurrent query quantity can be supported.

Optionally, in the multi-table paging query method provided in the embodiment of the present disclosure, the step S202 may be specifically executed by the following step S202 a:

s202a, the client receives and analyzes the first query result of the first data table sent by the server, and updates the query parameter to be the second query parameter based on the target data volume and the data volume in the first query result.

It should be noted that the data size in the first query result may be equal to or smaller than the target data size, and the specific value of the data size in the first query result is related to the data size stored in the first data table.

For example, the client may update the query parameter to the second query parameter based on a difference between the target amount of data and the amount of data in the first query result. The client may also update the query parameter to be the second query parameter based on a ratio of the target data amount to the data amount in the first query result.

Based on the scheme, the client can update the query parameters based on the target data volume and the data volume in the query result, so that the client can request the server to query by adopting the updated query parameters when querying next time.

Optionally, in the multi-table paging query method provided in the embodiment of the present disclosure, in the above-mentioned S202a, the "updating the query parameter to the second query parameter based on the target data size and the data size in the first query result" may be specifically performed in the following manner 1 or manner 2:

mode 1-1:

and if the data quantity in the first query result is equal to the target data quantity, updating the query page value to be a second page value.

And the second page value is the sum of the first page value and 1, and the second query request is used for requesting to return a second query result of the first data table.

Illustratively, assuming that the query page value in the first query parameter is preset to be 1, if the query page value in the updated query parameter is 2, the request is to continue to return the data in the first data table.

It is to be understood that if the amount of data in the first query result is equal to the target amount of data, the data representing the first data table may not have been returned.

It should be noted that, if the data amount in the query result returned for the second time is still equal to the target data amount, the query page value in the query parameter is continuously updated until the data amount in the query result returned is smaller than the target data amount, and the query page value is not updated any more.

Based on the scheme, the client can estimate whether all the data in the requested data table are returned to the client according to the data amount in the return result of the server, and under the condition that the data amount in the query result is equal to the target data amount, the data which is not returned to the client may exist in the first data table, so that the client can update the query page value in the query parameter to be the second page value in advance, so that the server can continue to return the data in the first data table according to the second page value. The total number of records of each sub-table does not need to be calculated by the server, the query logic of the server is simplified, and the return time of the server for returning data is shortened.

Mode 1 to 2:

and if the data quantity in the first query result is less than the target data quantity, updating the sub-table parameter value to be a second sub-table parameter value, and resetting the numerical value of the query page to be a first page value.

And the second sub-table parameter value is a sub-table parameter value adjacent to the first sub-table parameter value, the second sub-table parameter value corresponds to a second sub-table in the plurality of sub-tables, and the second query request is used for requesting to return a query result of the second sub-table.

It is understood that if the first data amount is smaller than the target data amount, the data of the first data table is completely returned to the client.

It should be noted that, the data amount in one query result may be equal to 0, that is, data is not returned, which indicates that all data in the data table corresponding to the query result has been returned to the client, and then the client may update the query parameter according to the above manner, and resend the query request to query the data in the next data table.

Based on the scheme, the client can estimate whether all the data in the requested data table are returned to the client according to the data amount in the returned query result, and under the condition that the data amount in the query result is smaller than the target data amount, the client can determine that all the data in the currently requested data table are returned, and then the client re-determines the value of the sub-table parameter, so that the server can directly determine the second data table for returning the data according to the second sub-table parameter value determined by the client, and the server is not required to perform logic operation to determine the data table for feeding back the data.

Optionally, in the method for querying a sub-table page provided in the embodiment of the present disclosure, the following step S204 may be further included:

and S204, if the updated sub-table parameter value is smaller than the minimum sub-table parameter value or larger than the maximum sub-table parameter value, the client outputs prompt information after receiving query input.

Wherein the hint information indicates that the query is terminated.

It should be noted that, in this scheme, the client no longer sends the query request to the server.

It should be noted that, in the query parameter initialized by the client, the value of the sub-table parameter value may be from small to large, or from large to small.

Exemplarily, assuming monthly table division, under the condition that the first table division parameter value in the initialized query parameters is the maximum month, if the updated table division parameter value is less than the minimum month, the client returns the prompt information; and under the condition that the first sub-table parameter value in the initialized query parameters is the minimum month, if the updated sub-table parameter value is larger than the maximum month, the client returns prompt information.

Based on the scheme, in the multi-table paging query process, if the sub-table parameter value updated by the client according to the query result is smaller than the minimum sub-table parameter value or larger than the maximum sub-table parameter value, the client can determine that the server does not have data to return to the client, the query can be terminated, and after the client receives the query input of the user, the client can output prompt information to prompt the user that the query is terminated and no more data exists.

Fig. 3 is a flowchart illustrating a multi-page sub-table lookup method according to an embodiment of the disclosure, as shown in fig. 3, the method may include the following steps S301 to S304:

s301, the server receives a first query request sent by the client.

Wherein the first query request includes a first query parameter. The first query parameter is a first sub-table parameter value, the query page value is a first page value, and the data amount of each page is a target data amount. The first sub-table parameter value corresponds to a first data table of a plurality of data tables, and the plurality of data tables are data tables split according to the sub-table parameter value.

Illustratively, the sub-table parameter is a day, week, month, quarter, or year.

Illustratively, the sub-table parameter is the last digit value of the user identification.

Illustratively, the sub-table parameter is a numerical value obtained by performing a hash operation and a modulo operation on a character string of the user identifier.

S302, the server side obtains a first data table according to the first table parameter value.

Specifically, the server searches a first data table corresponding to the first table parameter value from the plurality of data tables according to the first table parameter value.

S303, the server side conducts paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table, and sends the first query result to the client side.

S304, under the condition that the server receives a second query request sent by the client, the server searches the target data table in a paging mode according to the second query parameters.

Wherein the second query request includes a second query parameter. The second query parameter is a query parameter updated by the client according to the first query result, and the target data table is one of the data tables.

The method for multi-table paging query provided by the embodiment of the present disclosure includes that a server receives a first query request sent by a client, where the first query request includes a first query parameter, a value of a table parameter in the first query parameter is a first table parameter value, a value of a query page is a first page value, and a data size of each page is a target data size. Then, the server side can acquire a first data table corresponding to a first sub-table parameter value from a plurality of data tables split according to the sub-table parameter value; then, the server side can perform paging query on the first data table according to the first page value and the target data volume in the first query parameter to obtain a first query result of the first data table, and sends the first query result to the client side; and under the condition of receiving a second query request sent by the client, the server searches the target data table in a paging mode according to the second query parameter. Because the query parameters comprise the first sub-table parameter values, the server can directly determine the corresponding data table according to the sub-table parameter values, only the data table corresponding to the sub-table parameter values is subjected to paging query in one query process, and cross-table query is not required, so that the implementation logic of the server is simplified, the access times of the data table are reduced, the complexity of a query system is reduced, the performances of the server and a database are improved, and a foundation is provided for supporting higher concurrent query quantity.

Optionally, in the method for multi-table paging query provided in this embodiment of the present disclosure, the step "page query the target data table according to the updated query parameter" in the step S304 may be specifically performed in the following manner 2-1 or manner 2-2:

mode 2-1: if the sorting table parameter value in the second query parameter is a sorting table parameter value, the query page value is a second page value, and the data volume of each page is a target data volume, the server side obtains a second query result of the first data table according to the target data volume.

And the data volume in the first query result is equal to the target data volume.

For example, suppose that 10 data are requested to be returned each time in the query request, if the first data table includes 15 data, 10 data are returned to the client for the first time, 5 data remain, and 5 data remain to the client for the second time.

Based on the scheme, the server side does not need to calculate the offset of the data in the table, and can directly determine which data in the data table are returned according to the value of the query page in the query parameter sent by the client side, so that the implementation logic of the server side is simplified, and a foundation can be provided for the server side to support higher concurrent query quantity.

Mode 2-2: and if the sorting parameter value in the second query parameter is the second sorting parameter value, the value of the query page is the first page value, and the data volume of each page is the target data volume, the server side performs sorting query on a second data table in the plurality of data tables according to the second sorting parameter value.

And the data volume in the first query result is less than the target data volume, and the second sub-table parameter value corresponds to the second data table.

With reference to the above example, after the server sends the query result to the client for the second time, all the remaining 5 data in the first data table are returned to the client, the client determines that the data in the first data table have been returned according to the returned result, the client determines the sub-table parameter value of the next query as the second sub-table parameter value according to the query result, and sends the sub-table parameter value to the server, so that the server directly performs sub-table query on the second data table indicated by the second sub-table parameter value according to the query parameter.

Based on the scheme, the server does not need to calculate the data volume of each sub-table any more, the data of the calculation request is recorded in which data tables, one data table of the current query is directly determined according to the query parameters, and the data tables are subjected to paging query, so that the query logic of the server is simplified, and the performances of the server and the database are improved.

Fig. 4 is an interaction flow diagram of a multi-table paging query method according to an embodiment of the present disclosure. As shown in fig. 4, S401 to S407 including the following:

s401, if the first input is received, the client sends a first query request to the server.

S402, the server receives a first query request sent by the client.

And S403, the server side acquires a first data table according to the first table parameter value.

S404, the server performs paging query on the first data table according to the first page value and the target data volume to obtain a first query result of the first data table, and sends the first query result to the client.

S405, the client receives and analyzes the first query result sent by the server, and updates the query parameter into a second query parameter according to the first query result

S406, if the second input is received, the client sends a second query request to the server, so that the server queries the target data table according to the second query parameter.

S407, under the condition that the server receives a second query request sent by the client, the server searches the target data table in a paging mode according to the second query parameters.

It should be noted that, other steps of the client may refer to the description of the above embodiment of the client, and are not described herein again. Similarly, other steps of the server may refer to the description of the above embodiment of the server, and are not described herein again.

For example, to facilitate understanding of the multi-table paging query method according to the embodiment of the present disclosure, the following describes a conventional paging query and a multi-table paging query according to the embodiment of the present disclosure with reference to specific examples.

Example (c):

the order form splits the data table by month, assuming that the order form currently includes 4 months of 2021, order _202101, order _202102, order _202103, and order _202104, respectively. The total number of order records in the four tables is as follows: 5. 4, 11. The only identification of the order is the order _ id field in the data table, which is used to identify a record of the order. The four data tables are shown below.

TABLE 1

order_202101 A1 A2 A3 A4 A5

TABLE 2

order_202102 B1 B2 B3 B4

TABLE 3

order_202103 C1 C2 C3 C4

TABLE 4

order_202101 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 D11

Assuming that the current time month is 202104, the client needs to query the order records, and 10 are loaded per page using paging queries.

The traditional sub-table query mode comprises the following query steps:

the client sends the following query parameters to the server.

{

page:1

size:10

}

When receiving a first query request, the server firstly queries that the total number of data of the table order _202104 corresponding to the current month is 11, the total number is more than 10 (the number of loaded pieces per page), and returns [ D11, D10, D9, D8, D7, D6, D6, D5, D4, D3 and D2] as a query result of page 1.

When receiving a second query request, the server firstly queries that the total data number of the table order _202104 corresponding to the current month is 11, skips the previous 10 records, and takes out the remaining 1 record D1 of the table order _ 202104; then, the total number of data of the table order _202103 corresponding to the previous month is checked to be 4, and all the data C4, C3, C2 and C1 are extracted; then, the total number of data of the table order _202102 corresponding to the previous month is checked to be 4, and all the data B4, B3, B2 and B1 are taken out; then, the total number of data of the table order _202101 corresponding to the previous month is checked to be 5, and data A5 is taken out; return [ D1, C4, C3, C2, C1, B4, B3, B2, B1, a5] to the client as a query result for page 2.

When a third request is received, the server side adopts the mode to calculate from the first table again, the offset of the first 3 data needs to be calculated until the total number of the data calculated to the last table order _202101 is 5, the first 1 data is skipped, and the remaining 4 data A4, A3, A2 and A1 are taken out; return [ A4, A3, A2, A1] to the client as page 3 query results.

It can be understood that, in the conventional table-splitting paging query manner, 4 data tables are spanned when querying the 2 nd page data, and the implementation logic of the server is complex. When the page 3 data is queried, the offset of each data table is calculated.

The method for querying the multi-table pages provided by the embodiment of the disclosure comprises the following steps:

in the case of receiving a query input from a user in a client, the client may first request a range of queryable data tables from a server. The maximum month is recorded as month _ max, and the minimum month is month _ min. The client side initialization query parameters are as follows: 202104, page 1 and size 10.

The client sends the following query parameters to the server.

{

month:202104

page:1

size:10

}

When receiving the query parameter sent by the client, the server performs paging query on the data table order _202104 corresponding to month ═ 202104, and sends a query result 1 including [ D11, D10, D9, D8, D7, D6, D6, D5, D4, D3, and D2] to the client.

And the client modifies the query page number page to be 2 according to the condition that the number of the data in the query result 1 is equal to 10.

Under the condition that a first pull-down refreshing input of a user in a client is received, determining that new data needs to be loaded, and sending updated query parameters to a server by the client: 202104, page 2, and size 10.

The server continues to page the query in the data table order _202104 and sends query result 2, including [ D1], to the client.

And the client modifies month to 202103 and resets page to 1 according to the number of the data in the query result 2 being less than 10.

Under the condition that the second pull-down refreshing input of the user in the client is received, the client determines that new data needs to be loaded, and then the client sends updated query parameters to the server, wherein the updated query parameters are as follows: 202103, page 1 and size 10.

The server pages the query in the data table order _202103 according to month _202103 and page _ 1, and sends a query result 3 comprising [ C6, C5, C4, C3, C2 and C1] to the client.

And the client modifies month to 202102 and resets page to 1 according to the number of the data in the query result 3 being less than 10.

And the same is true when the modified month 202012 is smaller than month _ min, and the client receives the refresh input of pulling down in the client by the user again, and the client no longer sends the query request to the server, and the display shows that the data is not more.

According to the query mode provided by the embodiment of the disclosure, only one data table is subjected to paging query in each query request of the client, and compared with the traditional query mode, the implementation logic of the server is simplified, the access times of the data table are reduced, and the return speed of data is improved.

It should be noted that, in the multi-table paging query method provided in the embodiment of the present disclosure, an execution subject may be a multi-table paging query device, or a control module of the multi-table paging query device for executing the multi-table paging query method. The method for executing multi-table paging query by using the multi-table paging query device in the embodiment of the present disclosure is taken as an example, and the multi-table paging query device provided in the embodiment of the present disclosure is described.

Fig. 5 is a schematic structural diagram of a multi-table paging query device according to an embodiment of the disclosure, and as shown in fig. 5, the multi-table paging query device 500 includes: a sending module 501, a receiving module 502, an analyzing module 503 and an updating module 504; a sending module 501, configured to send a first query request if receiving a first input; the first query request comprises a first query parameter, the value of the table parameter in the first query parameter is a first table parameter value, the value of the query page is a first page value, and the data volume of each page is a target data volume; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; a receiving module 502, configured to receive a first query result sent by a server; the first query result is obtained by the server side performing paging query on the first data table; the analysis module 503 is configured to analyze the first query result received by the receiving module; an updating module 504, configured to update the query parameter to a second query parameter based on the first query result analyzed by the analyzing module 503; the sending module 501 is further configured to send a second query request to the server if receiving a second input, so that the server queries the target data table according to the second query parameter; the second query request includes a second query parameter, and the target data table is one of the plurality of data tables.

Optionally, the update module is specifically configured to: and updating the query parameter to be a second query parameter based on the target data volume and the data volume in the first query result.

Optionally, the update module is specifically configured to: if the data quantity in the first query result is equal to the target data quantity, updating the query page value to be a second page value; and the second page value is the sum of the first page value and 1, and the second query request is used for requesting to return a second query result of the first data table.

Optionally, the update module is specifically configured to: if the data quantity in the first query result is smaller than the target data quantity, updating the sub-table parameter value to be a second sub-table parameter value, and resetting the query page value to be a first page value; and the second sub-table parameter value is a sub-table parameter value adjacent to the first sub-table parameter value, the second sub-table parameter value corresponds to a second sub-table in the plurality of sub-tables, and the second query request is used for requesting to return a query result of the second sub-table.

Optionally, the multi-table paging query apparatus further includes: an output module; the output module is used for outputting prompt information after receiving query input if the updated sub-table parameter value is smaller than the minimum sub-table parameter value or larger than the maximum sub-table parameter value, and the prompt information indicates that the query is terminated.

Optionally, the sub-table parameter is day, week, month, quarter, or year; or, the sub-table parameter is the last numerical value of the user identifier; or, the sub-table parameter is a numerical value obtained by performing hash operation and modulo operation on the character string of the user identifier.

The multi-table paging query device provided by the embodiment of the disclosure can implement each process of the client in the embodiment of the multi-table paging query method, and can achieve the same technical effect, and is not repeated here to avoid repetition.

Fig. 6 is a schematic structural diagram of a multi-table paging query apparatus according to an embodiment of the disclosure, as shown in fig. 6, the multi-table paging query apparatus 600 includes: a receiving module 601, an obtaining module 602, a querying module 603 and a sending module 604; a receiving module 601, configured to receive a first query request sent by a client, where the first query request includes a first query parameter, a value of a table parameter in the first query parameter is a first table parameter value, a value of a query page is a first page value, and a data amount of each page is a target data amount; the first sub-table parameter value corresponds to a first data table in a plurality of data tables, and the data tables are split according to the sub-table parameter value; an obtaining module 602, configured to obtain a first data table according to a first table parameter value; the query module 603 is configured to perform paging query on the first data table according to the first page value and the target data size to obtain a first query result of the first data table; a sending module 604, configured to send the first query result to the client; the query module 603 is further configured to query the target data table in a paging manner according to the second query parameter when receiving a second query request sent by the client, where the second query request includes the second query parameter, the second query parameter is a query parameter updated by the client according to the first query result, and the target data table is one of the multiple data tables.

Optionally, the query module is specifically configured to: if the value of the sorting table parameter in the second query parameter is the first sorting table parameter value, the value of the query page is the second page value, and the data volume of each page is the target data volume, acquiring a second query result of the first data table according to the target data volume; and the data volume in the first query result is equal to the target data volume.

Optionally, the query module is specifically configured to: if the value of the sorting table parameter in the second query parameter is the second sorting table parameter value, the value of the query page is the first page value, and the data volume of each page is the target data volume, performing sorting query on a second data table in the plurality of data tables according to the second sorting table parameter value; and the data volume in the first query result is less than the target data volume, and the second sub-table parameter value corresponds to the second data table.

Optionally, the sub-table parameter is day, week, month, quarter, or year; or, the sub-table parameter is the last numerical value of the user identifier; or, the sub-table parameter is a numerical value obtained by performing hash operation and modulo operation on the character string of the user identifier.

The multi-table paging query device provided in the embodiments of the present disclosure can implement each process of the server in the embodiments of the multi-table paging query method, and can achieve the same technical effect, and is not described herein again to avoid repetition.

The multi-table paging inquiry apparatus in the embodiments of the present disclosure may be an apparatus, or may be a component, an integrated circuit, or a chip in a terminal. The device can be mobile electronic equipment or non-mobile electronic equipment. By way of example, the mobile electronic device may be a mobile phone, a tablet computer, a notebook computer, a palm top computer, a vehicle-mounted electronic device, a wearable device, a UMPC (ultra-mobile personal computer), a netbook, a PDA (personal digital assistant), or the like, and the non-mobile electronic device may be a server, a NAS (Network Attached Storage), a PC (personal computer), a TV (television), a teller machine, a self-service machine, or the like, and the disclosed embodiments are not limited in particular.

The multi-table paging query device in the embodiments of the present disclosure may be a device having an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, and the embodiment of the present disclosure is not limited specifically.

The multi-table paging query device provided in the embodiment of the present disclosure can implement each process implemented by the method embodiments of fig. 1 to fig. 4, and is not described herein again to avoid repetition.

Optionally, as shown in fig. 7, an embodiment of the present disclosure further provides a client 700, which includes a processor 701, a memory 702, and a program or an instruction stored in the memory 702 and executable on the processor 701, where the program or the instruction is executed by the processor 701 to implement each process of the foregoing multi-table paging query method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.

It should be noted that the client in the embodiment of the present disclosure includes the mobile electronic device and the non-mobile electronic device described above.

Fig. 8 is a schematic diagram of a hardware structure of a client implementing an embodiment of the present disclosure.

The client 800 includes but is not limited to: a radio frequency unit 801, a network module 802, an audio output unit 803, an input unit 804, a sensor 805, a display unit 806, a user input unit 807, an interface unit 808, a memory 809, and a processor 810.

Those skilled in the art will appreciate that client 800 may further include a power supply (e.g., a battery) for supplying power to various components, and the power supply may be logically connected to processor 810 via a power management system, so as to implement functions of managing charging, discharging, and power consumption via the power management system. The client architecture shown in fig. 8 does not constitute a limitation on the client, which may include more or fewer components than shown, or combine certain components, or a different arrangement of components, and will not be described again here.

The client provided by the embodiment of the present disclosure can implement each process of the above-mentioned multi-table paging query method embodiment, and can achieve the same technical effect, and for avoiding repetition, details are not repeated here.

It is to be understood that, in the embodiment of the present disclosure, the input Unit 804 may include a GPU (Graphics Processing Unit) 841 and a microphone 842, and the Graphics processor 841 processes image data of still pictures or videos obtained by an image capturing device (such as a camera) in a video capturing mode or an image capturing mode. The display unit 806 may include a display panel 861, and the display panel 861 may be configured in the form of a liquid crystal display, an organic light emitting diode, or the like. The user input unit 807 includes a touch panel 871 and other input devices 872. Touch panel 871, also referred to as a touch screen. The touch panel 871 may include two parts of a touch detection device and a touch controller. Other input devices 872 may include, but are not limited to, a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, and a joystick, which are not described in detail herein. The memory 809 may be used to store software programs as well as various data including, but not limited to, application programs and operating systems. The processor 810 may integrate an application processor, which mainly handles operating systems, user interfaces, application programs, etc., and a modem processor, which mainly handles wireless communications. It will be appreciated that the modem processor described above may not be integrated into processor 810.

Optionally, as shown in fig. 9, an embodiment of the present disclosure further provides a server 900, which includes a processor 901, a memory 902, and a program or an instruction stored in the memory 902 and executable on the processor 901, where the program or the instruction is executed by the processor 901 to implement each process of the foregoing multi-table paging query method embodiment, and can achieve the same technical effect, and in order to avoid repetition, the details are not described here again.

Fig. 10 is a schematic hardware structure diagram of a server for implementing an embodiment of the present disclosure.

It should be noted that the server 1000 shown in fig. 10 is only an example, and should not bring any limitation to the functions and the scope of the embodiments of the present disclosure.

As shown in fig. 10, the server 1000 includes a CPU (Central Processing Unit) 1001 that can perform various appropriate actions and processes according to a program stored in a ROM (Read-Only Memory) 1002 or a program loaded from a storage section 1008 into a RAM (Random Access Memory) 1003. In the RAM 1003, various programs and data necessary for system operation are also stored. The CPU 1001, ROM 1002, and RAM 1003 are connected to each other via a bus 1004. An I/O (Input/Output) interface 1005 is also connected to the bus 1004.

The following components are connected to the I/O interface 1005: an input section 1006 including a keyboard, a mouse, and the like; an output section 1007 including a CRT (Cathode Ray Tube), LCD (Liquid Crystal Display), and the like, a speaker, and the like; a storage portion 1008 including a hard disk and the like; and a communication section 1009 including a Network interface card such as a LAN (Local Area Network) card, a modem, or the like. The communication section 1009 performs communication processing via a network such as the internet. The driver 1010 is also connected to the I/O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 1010 as necessary, so that a computer program read out therefrom is mounted into the storage section 1008 as necessary.

In particular, according to an embodiment of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication part 1009 and/or installed from the removable medium 1011. When the computer program is executed by the CPU 1001, various functions defined in the system of the present application are executed.

The server provided by the embodiment of the disclosure can implement each process of the multi-table paging query method embodiment, and can achieve the same technical effect, and is not described herein again to avoid repetition.

The embodiments of the present disclosure further provide a readable storage medium, where a program or an instruction is stored on the readable storage medium, and when the program or the instruction is executed by a processor, the program or the instruction implements each process of the above-mentioned multi-table paging query method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.

Wherein, the processor is the processor in the server described in the above embodiment. The readable storage medium includes a computer readable storage medium, such as a computer ROM, a computer RAM, a magnetic or optical disk, and the like.

The embodiment of the present disclosure further provides a chip, where the chip includes a processor and a communication interface, the communication interface is coupled to the processor, and the processor is configured to run a program or an instruction to implement each process of the above-mentioned multi-table paging query method embodiment, and can achieve the same technical effect, and in order to avoid repetition, details are not repeated here.

It should be understood that the chips mentioned in the embodiments of the present disclosure may also be referred to as system-on-chip, system-on-chip or system-on-chip, etc.

It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Further, it is noted that the scope of the methods and apparatus in the embodiments of the present disclosure is not limited to performing functions in the order shown or discussed, but may include performing functions in a substantially simultaneous manner or in a reverse order based on the functions involved, e.g., the methods described may be performed in an order different than that described, and various steps may be added, omitted, or combined. In addition, features described with reference to certain examples may be combined in other examples.

Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solutions of the present disclosure may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) and includes instructions for enabling a terminal (e.g., a mobile phone, a computer, a server, an air conditioner, or a network device) to execute the method according to the embodiments of the present disclosure.

While the present disclosure has been described with reference to the embodiments illustrated in the drawings, which are intended to be illustrative rather than restrictive, it will be apparent to those of ordinary skill in the art in light of the present disclosure that many more modifications may be made without departing from the spirit of the disclosure and the scope of the appended claims.

完整详细技术资料下载
上一篇:石墨接头机器人自动装卡簧、装栓机
下一篇:一种基于多维度的案件合并方法、装置及存储介质

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!