Data query method and device
By introducing an asynchronous processing method into the database server, whether to use asynchronous processing is determined based on the amount of data of the query results, the problems of low response efficiency and large resource utilization in the existing technology are solved, and an efficient data query solution is realized.
Patent Information
- Application Number
- CN202410660039.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, when responding to client query requests, the synchronization mechanism causes the application server to be inefficient in response to low response efficiency. Although the asynchronous mechanism can improve response efficiency, it will occupy application server resources.
By introducing an asynchronous processing method into the database server, whether to use asynchronous processing is determined based on the amount of data of the query result. If it is greater than the set threshold, the asynchronous processing server will be processed asynchronously and notified the client to poll to obtain the results to avoid occupancy of application server resources.
It realizes the improvement of response efficiency while reducing the use of application server resources when responding to client requests, and provides an efficient data query solution that does not occupy application server resources for a long time.
Smart Images

Figure CN119474507A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of database technology, and in particular to a data query method and device. Background Art
[0002] The current query service generally starts with the client initiating a query request to the application server and obtaining the query result data returned by the application server. The query result data is generally persistently stored in the backend component database. The backend database stores a large amount of data and has complex logical processing, which results in a long time for the application server to respond to the query request. In particular, when using a synchronous mechanism to respond to query requests, the client needs to wait for the application server to obtain complete data before performing subsequent processing. Correspondingly, the asynchronous mechanism can effectively improve the response efficiency, but the asynchronous mechanism will occupy the resources and network of the application server to handle other synchronous processing processes. Summary of the invention
[0003] The present application provides a data query method and device for improving response efficiency while reducing the occupancy of application server resources by using an asynchronous processing method when responding to client requests.
[0004] In a first aspect, the present application proposes a data query method, which is applied to a database server and includes:
[0005] Receive data query requests from clients forwarded by the application server;
[0006] Acquire query results from the database according to the data query request;
[0007] When the data volume of the query result is greater than a first set threshold, an asynchronous notification message is sent to the client through the application server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and is used to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result;
[0008] Asynchronous indication information is sent to the asynchronous processing server to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner, and after the processing is completed, the query result is sent to the client based on the polling request initiated by the client.
[0009] Based on the above scheme, this application proposes to start the asynchronous processing mode when the amount of data requested by the client is large. In order not to occupy the resources of the normal synchronous processing process of the application server, it is proposed to use an independent asynchronous processing server to process the query request of the client, and at the same time notify the client through the application server to poll the asynchronous processing server to obtain the query result. A data query solution that does not occupy the synchronous processing resources of the application server and is efficient is realized.
[0010] In some embodiments, before sending the asynchronous indication information to the asynchronous processing server, the method further includes:
[0011] Determine whether the data volume is less than a second set threshold; the second set threshold is greater than the first set threshold;
[0012] When the data volume is less than the second set threshold, generating asynchronous indication information carrying the query result;
[0013] When the data volume is not less than the second set threshold, the address of the file corresponding to the query result in the database is determined, and asynchronous indication information carrying the address is generated.
[0014] Based on the above solution, when the data volume is small, the data is sent in the form of a message to ensure the timeliness of the client's acquisition of data. When the data volume is large, it is returned to the client in the form of a file to improve the integrity of the data.
[0015] In some embodiments, the data query request carries the target serial number corresponding to the client, and the polling request initiated by the client carries the target serial number; and sending the asynchronous indication information to the asynchronous processing server specifically includes:
[0016] Asynchronous indication information carrying the target serial number is sent to the asynchronous processing server, so that the asynchronous processing server verifies the polling request based on the target serial number.
[0017] Since the client does not directly send the data query request to the asynchronous processing server, this application sets up a verification mechanism based on a trace ID to protect the data transmission between the client and the asynchronous processing server.
[0018] In some embodiments, after receiving the data query request from the client forwarded by the application server, the method further includes:
[0019] When the data volume of the query result is not greater than the first set threshold, a synchronization indication message carrying the query result is sent to the application server to instruct the application server to process the data query request in a synchronous processing manner and return the query result to the client after the processing is completed.
[0020] In a second aspect, the present application proposes a data query method, which is applied to an asynchronous processing server and includes:
[0021] Receiving asynchronous indication information sent by a database server; the asynchronous indication information is sent by the database server when it determines that the amount of data in the query result is greater than a first set threshold after receiving a data query request sent by a client;
[0022] The data query request is processed in an asynchronous processing manner, and after the processing is completed, the query result is sent to the client based on the polling request initiated by the client.
[0023] In some embodiments, sending the query result to the client based on the polling request initiated by the client specifically includes:
[0024] When it is determined that the asynchronous indication information carries the query result, sending the query result to the client through the redis component based on the polling request;
[0025] When it is determined that the asynchronous indication information carries a file address, the file corresponding to the to-be-processed data is obtained from the database server according to the file address; and the file is sent to the client based on the polling request.
[0026] In some embodiments, before sending the file to the client based on the polling request, the method further includes:
[0027] The file obtained from the database server is converted into a file in the target format required by the client.
[0028] In some embodiments, the asynchronous indication information carries a target serial number corresponding to the client; before sending the query result to the client based on the polling request initiated by the client, the method further includes:
[0029] The polling request initiated by the client is verified based on the target serial number.
[0030] In a third aspect, the present application proposes a data query method, which is applied to a client and includes:
[0031] Sending a data query request to a database server through an application server, and receiving an asynchronous notification message returned by the database server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and the asynchronous notification message is sent by the database server when the query result is not less than a first set threshold;
[0032] Initiate a polling request to the asynchronous processing server based on the asynchronous notification message;
[0033] Receive the query result returned by the asynchronous processing server.
[0034] In a fourth aspect, the present application proposes a data query device, which is applied to a database server, or the device is the database server, and the device includes:
[0035] A communication unit, used to receive a data query request from a client forwarded by an application server;
[0036] A processing unit, configured to obtain a query result from a database according to the data query request;
[0037] The processing unit is further configured to instruct the communication unit to send an asynchronous notification message to the client through the application server when the amount of data in the query result is greater than a first set threshold; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and is configured to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result;
[0038] The communication unit is also used to send asynchronous indication information to the asynchronous processing server, which is used to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner, and after the processing is completed, send the query result to the client based on the polling request initiated by the client.
[0039] In some embodiments, the processing unit is further configured to:
[0040] Determine whether the data volume is less than a second set threshold; the second set threshold is greater than the first set threshold;
[0041] When the data volume is less than the second set threshold, generating asynchronous indication information carrying the query result;
[0042] When the data volume is not less than the second set threshold, the address of the file corresponding to the query result in the database is determined, and asynchronous indication information carrying the address is generated.
[0043] In some embodiments, the data query request carries the target serial number corresponding to the client, and the polling request initiated by the client carries the target serial number; the communication unit is specifically used to:
[0044] Asynchronous indication information carrying the target serial number is sent to the asynchronous processing server, so that the asynchronous processing server verifies the polling request based on the target serial number.
[0045] In some embodiments, the processing unit is further configured to:
[0046] When the data volume of the query result is not greater than the first set threshold, the communication unit is instructed to send synchronization indication information carrying the query result to the application server, so as to instruct the application server to process the data query request in a synchronous processing manner and return the query result to the client after the processing is completed.
[0047] In a fifth aspect, the present application proposes a data query device, which is applied to an asynchronous processing server, or the device is the asynchronous processing server, and the device includes:
[0048] A communication unit, configured to receive asynchronous indication information sent by a database server; the asynchronous indication information is sent by the database server when it determines that the amount of data in the query result is greater than a first set threshold after receiving a data query request sent by a client;
[0049] The processing unit is used to process the data query request in an asynchronous processing manner, and after the processing is completed, instruct the communication unit to send the query result to the client based on the polling request initiated by the client.
[0050] In some embodiments, the processing unit is specifically configured to:
[0051] When it is determined that the asynchronous indication information carries the query result, instructing the communication unit to send the query result to the client through the redis component based on the polling request;
[0052] When it is determined that the asynchronous indication information carries a file address, the file corresponding to the to-be-processed data is obtained from the database server according to the file address; and the communication unit is instructed to send the file to the client based on the polling request.
[0053] In some embodiments, the processing unit is further configured to:
[0054] The file obtained from the database server is converted into a file in the target format required by the client.
[0055] In some embodiments, the asynchronous indication information carries a target serial number corresponding to the client; and the processing unit is further configured to:
[0056] The polling request initiated by the client is verified based on the target serial number.
[0057] In a sixth aspect, the present application proposes a data query device, which is applied to a client, or the device is the client, and the device includes:
[0058] A communication unit, configured to send a data query request to a database server through an application server, and receive an asynchronous notification message returned by the database server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and the asynchronous notification message is sent by the database server when the query result is not less than a first set threshold;
[0059] A processing unit, configured to initiate a polling request to an asynchronous processing server based on the asynchronous notification message;
[0060] The communication unit is also used to receive the query result returned by the asynchronous processing server.
[0061] In a seventh aspect, the present application proposes a data query system, the system comprising:
[0062] The client is used to send data query requests to the database server through the application server;
[0063] The database server is configured to obtain a query result from the database according to the data query request; when the amount of data in the query result is greater than a first set threshold, send an asynchronous notification message to the client through the application server, and send asynchronous indication information to the asynchronous processing server;
[0064] The client is further configured to initiate a polling request to the asynchronous processing server based on the asynchronous notification message;
[0065] The asynchronous processing server is used to process the data query request in an asynchronous processing manner according to the instruction of the asynchronous indication information, and send the query result to the client based on the polling request initiated by the client after the processing is completed.
[0066] In some embodiments, the system further comprises an application server,
[0067] The database server is further configured to send synchronization indication information carrying the query result to the application server when the data volume of the query result is not greater than the first set threshold;
[0068] The application server is used to process the data query request in a synchronous processing manner based on the synchronization indication information, and return the query result to the client after the processing is completed.
[0069] In an eighth aspect, the present application provides an electronic device, including:
[0070] A memory for storing program instructions;
[0071] The processor is used to call the program instructions stored in the memory, and execute the steps included in any one of the methods of the first aspect to the third aspect according to the obtained program instructions.
[0072] In a ninth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes any one of the methods described in the first to third aspects.
[0073] In a tenth aspect, the present application provides a computer program product, comprising: a computer program code, when the computer program code is run on a computer, the computer executes any one of the methods in the first to third aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for describing the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application.
[0075] Figure 1 A schematic diagram of a client data query scenario provided in an embodiment of the present application;
[0076] Figure 2 A schematic diagram of a data query scenario architecture provided in an embodiment of the present application;
[0077] Figure 3 A flowchart of a data query method provided in an embodiment of the present application;
[0078] Figure 4 A schematic diagram of a data query process provided in an embodiment of the present application;
[0079] Figure 5 A schematic diagram of the structure of a data query device provided in an embodiment of the present application;
[0080] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0081] In order to make the purpose, technical scheme and advantages of the present application clearer, the technical scheme in the embodiment of the present application will be clearly and completely described below in conjunction with the drawings in the embodiment of the present application. Obviously, the described embodiment is only a part of the embodiment of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work are within the scope of protection of the present application. In the absence of conflict, the embodiments in the present application and the features in the embodiments can be arbitrarily combined with each other. In addition, although the logical order is shown in the flow chart, in some cases, the steps shown or described can be performed in an order different from that here.
[0082] The terms "first" and "second" in the specification and claims of this application and the above-mentioned drawings are used to distinguish different objects, rather than to describe a specific order. For example, a process, method, system, product or device comprising a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices. "Multiple" in this application can mean at least two, for example, two, three or more, and the embodiments of the present application are not limited.
[0083] The following is a description of exemplary embodiments of the present application in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope of the present application. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description. It should be noted that in the embodiments of the present application, certain software, components, models and other existing solutions in the industry may be mentioned, which should be considered as exemplary, and their purpose is only to illustrate the feasibility of the implementation of the technical solution of the present application, but it does not mean that the applicant has or will necessarily use the solution.
[0084] In the technical solution of this application, the acquisition, transmission, storage, and use of data are in compliance with the requirements of relevant national laws and regulations.
[0085] Before introducing the data query method provided by the embodiment of the present application, in order to facilitate understanding, the technical background of the embodiment of the present application is first described in detail. Figure 1As shown, in the current browser / server (BrowserServer, BS) mode, the client will initiate a data query request to the application server. After receiving the request, the application server will start an asynchronous processing method or a synchronous processing method to process the data query request according to user needs, and obtain the response data from the database server and return it to the client. However, due to the large amount of data stored in the database server and the complex logical processing, the efficiency of the application server in responding to client requests is low. Especially in the synchronous processing method, the application server needs to obtain complete data before responding to the client, and the user experience is poor. When the asynchronous processing method is adopted, although the response efficiency can be improved, the asynchronous process will occupy the resources of other synchronous processes of the application server. Therefore, there is currently no efficient response solution that does not occupy application server resources for a long time.
[0086] In view of this, the present application proposes a data query solution, in which the back-end database server determines whether to use synchronous processing or asynchronous processing according to the size of the requested data. If the synchronous processing is used, the requested data is returned directly through the application server; otherwise, if the asynchronous processing is used, the independent asynchronous processing server is notified to respond to the client's request and return the requested data to the client based on the client polling method. Compared with the traditional synchronous processing method, the response efficiency can be effectively improved, and the asynchronous processing process of the present application will not occupy other synchronous processing resources of the application server.
[0087] In order to facilitate understanding of the solution of the present application, the following first introduces the scenarios to which the solution of the present application is applicable. Figure 2 , is a schematic diagram of a data query scenario architecture provided in an embodiment of the present application, specifically including: a database server, an asynchronous processing server, an application server and a client.
[0088] Exemplarily, the client may also be referred to as a User Equipment (UE), a Mobile Station (MS), a Mobile Terminal (MT), etc., which is a device that provides voice and / or data connectivity to a user, for example, a handheld device with a wireless connection function, a vehicle-mounted device, etc. At present, some examples of terminal devices are: mobile phones, tablet computers, laptop computers, PDAs, mobile Internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminal devices in industrial control, wireless terminal devices in self driving, wireless terminal devices in remote medical surgery, wireless terminal devices in smart grids, wireless terminal devices in transportation safety, wireless terminal devices in smart cities, wireless terminal devices in smart homes, etc.
[0089] Figure 2 The application server shown in the figure is used to provide a variety of services to the client, and can directly receive various service requests sent by the client, including data query requests. For example, the asynchronous processing server proposed in this application is a server independent of the application server, which is dedicated to processing the client's data query request using an asynchronous processing method and feeding back the query result to the client. For example, Figure 2 The database server shown can also be called a database component, which includes a database for storing various data and has the function of adding, deleting, querying, and modifying the data in the database. It should be noted that this application does not limit the type of database used, for example, a distributed database can be used. In addition, this application does not limit the number of servers and clients included in the data query scenario. Figure 2 The scene architecture shown is provided as an example only.
[0090] Next, combine Figure 2 The scenario shown is a specific introduction to the solution of the present application. For example, see Figure 3 , is a flow chart of a data query method provided in an embodiment of the present application, specifically including:
[0091] 301. The client sends a data query request to the database server.
[0092] It should be noted that the data query request sent by the client is forwarded to the database server through the application server. Figure 3 This process is not shown in FIG.
[0093] 302. The database server obtains a query result from the database according to the data query request, and sends an asynchronous notification message to the client when it is determined that the data volume of the query result is greater than a first set threshold.
[0094] Similar to step 301, the asynchronous notification message sent by the database server is also forwarded to the client through the application server. Figure 3 This process is not shown in FIG.
[0095] The asynchronous notification message indicates that the client's data query request has triggered the asynchronous processing mode, and is used to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result.
[0096] 303. The database server sends asynchronous indication information to the asynchronous processing server.
[0097] The asynchronous indication information is used to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner. It should be noted that the present application does not limit the execution process of step 302 and step 303. When the database server determines that the amount of data in the query result is greater than the first set threshold, step 302 and step 303 can be executed simultaneously.
[0098] 304. The client initiates a polling request to the asynchronous processing server according to the asynchronous notification message.
[0099] 305, the asynchronous processing server processes the data query request in an asynchronous processing manner, and sends the query result to the client based on the polling request after the processing is completed.
[0100] Based on the above scheme, this application proposes to start the asynchronous processing mode when the amount of data requested by the client is large. In order not to occupy the resources of the normal synchronous processing process of the application server, it is proposed to use an independent asynchronous processing server to process the query request of the client, and at the same time notify the client to poll the asynchronous processing server to obtain the query result through the application server. A response scheme for data query that does not occupy the synchronous processing resources of the application server and is efficient is realized.
[0101] In a possible case, if the amount of data requested by the client is small, a synchronous processing method can be used to respond to the client's request. Exemplarily, when the database server determines that the amount of data in the client's query result is not greater than the first set threshold, it can send a synchronization indication message to the application server. The synchronization indication message directly carries the query result. Thus, the application server can use a synchronous processing method to process the data query request sent by the client, and return the query result to the client after the processing is completed.
[0102] In some embodiments, when the amount of data requested by the client is large and asynchronous processing needs to be initiated, since the client does not directly send the data query request to the asynchronous processing server, the present application sets up a verification mechanism based on a trace ID to protect the data transmission between the client and the asynchronous processing server.
[0103] In a possible implementation, before sending a data query request, the client may generate a unique request serial number, and carry it in the data query request and send it to the database server. For ease of description, the unique request serial number is referred to as the target serial number in the following. After receiving the data query request and determining that the asynchronous processing mode needs to be started, the database server may send an asynchronous indication message carrying the target serial number to the asynchronous processing server, and at the same time send an asynchronous notification message to the client, instructing the client to initiate a polling request to the asynchronous processing server. The client may send a polling request carrying the target serial number to the asynchronous processing server.
[0104] Furthermore, when the asynchronous processing server receives the polling request from the client, it can determine whether the serial number carried therein is the same as the target serial number received from the database server. If they are the same, the query result is sent to the client. If they are not the same, the query result is not sent to the client.
[0105] In some embodiments, when responding to a data query request from a client, the database server may further determine the form of data return based on the amount of data. In one possible case, when the amount of data in the query result is less than a second set threshold, the query result may be directly carried in the asynchronous indication information and sent to the asynchronous processing server. For example, when the asynchronous indication information is sent in the form of a message, the query result may be added to the message and sent to the asynchronous processing server together. The second set threshold is greater than the first set threshold.
[0106] In another possible case, when the data volume of the query result is not less than the second set threshold, the query result can be sent in the form of a file. Exemplarily, the database server can determine the address of the file corresponding to the query result in the database, and send asynchronous indication information carrying the file address to the asynchronous processing server. Further, the asynchronous processing server can obtain the file from the corresponding file address.
[0107] Exemplarily, when the query result is carried in the asynchronous indication information and sent to the asynchronous processing server, the asynchronous processing server can quickly process the data query request through the redis component when receiving the polling request from the client, and send the query result to the client. Based on the above scheme, when the amount of data is small, the data is sent in the form of a message to ensure the timeliness of the client's acquisition of data. Optionally, in order to further ensure the timeliness of the client's acquisition of data, the present application proposes that the client can also use instant messaging tools such as openfire to communicate with the asynchronous processing server to obtain query results.
[0108] When the query results are returned in the form of files, the asynchronous processing server can convert the files into the format required by the client after obtaining the files, and send the converted files to the client when receiving the polling request. Based on the above solution, large amounts of data are returned to the client in the form of files, which improves the validity of the data.
[0109] Furthermore, when the client receives the query result in the form of data, the query result can be displayed on a display page. When the client receives the query result in the form of a file, the user can be notified to download or print the file on the display page.
[0110] In order to further understand the solution of the present application, the following is an introduction in conjunction with specific embodiments. Figure 4 , is a schematic diagram of a data query process provided in an embodiment of the present application, specifically including:
[0111] 401: The client sends a data query request to the application server.
[0112] 402. The application server forwards the data query request to the database server.
[0113] 403. The database server determines whether the data volume of the query result is greater than a first set threshold.
[0114] Exemplarily, the database server may obtain query results from the backend database according to the data query request.
[0115] If it is not greater, it indicates that the synchronous processing mode needs to be started, and then steps 404A-405A are continued.
[0116] If it is greater, it indicates that the asynchronous processing mode needs to be started, and then the steps 404B-409B are continued.
[0117] 404A, the database server sends synchronization indication information to the application server.
[0118] 405A, the application server receives the synchronization indication information, processes the data query request in a synchronous processing manner, and sends the query result to the client after the processing is completed.
[0119] 404B, the database server sends an asynchronous notification message to the application server.
[0120] 405B, the application server forwards the asynchronous notification message to the client.
[0121] Exemplarily, for the introduction of the asynchronous notification message, reference may be made to the relevant description in the above embodiment, which will not be repeated here.
[0122] 406B: The database server sends asynchronous indication information to the asynchronous processing server.
[0123] 407B, the asynchronous processing server receives the asynchronous indication information, processes the data query request in an asynchronous processing manner, and obtains the query result.
[0124] Optionally, the query result obtained by the asynchronous processing server may be in the form of a file or in the form of data. The specific form may be referred to the relevant introduction in the above embodiment, which will not be described in detail here.
[0125] It should be noted that the present application does not limit the execution order of steps 404B-405B and steps 406B-407B.
[0126] 408B: The client initiates a polling request to the asynchronous processing server according to the asynchronous notification message.
[0127] 409B, the asynchronous processing server receives the polling request and returns the query result to the client.
[0128] Based on the same concept as the above method, see Figure 5 , is a data query device 500 provided in an embodiment of the present application, the device 500 is used to implement each step in the above method embodiment, and in order to avoid repetition, it will not be described again here. The device 500 includes: a communication unit 501 and a processing unit 502.
[0129] In one possible scenario:
[0130] The communication unit 501 is used to receive a data query request from a client forwarded by an application server;
[0131] The processing unit 502 is used to obtain the query result from the database according to the data query request;
[0132] The processing unit 502 is further configured to instruct the communication unit 501 to send an asynchronous notification message to the client through the application server when the amount of data in the query result is greater than a first set threshold; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and is configured to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result;
[0133] The communication unit 501 is also used to send asynchronous indication information to the asynchronous processing server, which is used to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner, and send the query result to the client based on the polling request initiated by the client after the processing is completed.
[0134] In some embodiments, the processing unit 502 is further configured to:
[0135] Determine whether the data volume is less than a second set threshold; the second set threshold is greater than the first set threshold;
[0136] When the data volume is less than the second set threshold, generating asynchronous indication information carrying the query result;
[0137] When the data volume is not less than the second set threshold, the address of the file corresponding to the query result in the database is determined, and asynchronous indication information carrying the address is generated.
[0138] In some embodiments, the data query request carries the target serial number corresponding to the client, and the polling request initiated by the client carries the target serial number; the communication unit 501 is specifically used to:
[0139] Asynchronous indication information carrying the target serial number is sent to the asynchronous processing server, so that the asynchronous processing server verifies the polling request based on the target serial number.
[0140] In some embodiments, the processing unit 502 is further configured to:
[0141] When the data volume of the query result is not greater than the first set threshold, the communication unit 501 is instructed to send synchronization indication information carrying the query result to the application server, so as to instruct the application server to process the data query request in a synchronous processing manner and return the query result to the client after the processing is completed.
[0142] Another possible scenario:
[0143] The communication unit 501 is used to receive asynchronous indication information sent by the database server; the asynchronous indication information is sent by the database server when it determines that the data volume of the query result is greater than a first set threshold after receiving the data query request sent by the client;
[0144] The processing unit 502 is used to process the data query request in an asynchronous processing manner, and after the processing is completed, instruct the communication unit 501 to send the query result to the client based on the polling request initiated by the client.
[0145] In some embodiments, the processing unit 502 is specifically configured to:
[0146] When it is determined that the asynchronous indication information carries the query result, instructing the communication unit 501 to send the query result to the client through the redis component based on the polling request;
[0147] When it is determined that the asynchronous indication information carries a file address, the file corresponding to the to-be-processed data is obtained from the database server according to the file address; and the communication unit 501 is instructing to send the file to the client based on the polling request.
[0148] In some embodiments, the processing unit 502 is further configured to:
[0149] The file obtained from the database server is converted into a file in the target format required by the client.
[0150] In some embodiments, the asynchronous indication information carries a target serial number corresponding to the client; the processing unit 502 is further configured to:
[0151] The polling request initiated by the client is verified based on the target serial number.
[0152] Another possible scenario:
[0153] The communication unit 501 is used to send a data query request to a database server through an application server, and receive an asynchronous notification message returned by the database server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and the asynchronous notification message is sent by the database server when the query result is not less than a first set threshold;
[0154] A processing unit 502 is configured to initiate a polling request to an asynchronous processing server based on the asynchronous notification message;
[0155] The communication unit 501 is further configured to receive the query result returned by the asynchronous processing server.
[0156] Figure 6 The electronic device 600 in the embodiment of the present application may further include a communication interface 603, which is, for example, a network port, through which the electronic device may transmit data. For example, the communication interface 603 may be used to implement the above Figure 5 The function of the communication unit 501.
[0157] In the embodiment of the present application, the memory 602 stores instructions that can be executed by at least one processor 601. The at least one processor 601 can be used to execute each step in the above method by executing the instructions stored in the memory 602. For example, the processor 601 can implement the above Figure 5 The function of the processing unit 502 in.
[0158] Among them, the processor 601 is the control center of the electronic device, and can use various interfaces and lines to connect various parts of the entire electronic device, by running or executing instructions stored in the memory 602 and calling data stored in the memory 602. Optionally, the processor 601 may include one or more processing units, and the processor 601 may integrate an application controller and a modem controller, wherein the application controller mainly processes the operating system and application programs, and the modem controller mainly processes wireless communications. It is understandable that the above-mentioned modem controller may not be integrated into the processor 601. In some embodiments, the processor 601 and the memory 602 may be implemented on the same chip, and in some embodiments, they may also be implemented separately on independent chips.
[0159] The processor 601 may be a general controller, such as a central processing unit (CPU), a digital signal controller, an application specific integrated circuit, a field programmable gate array or other programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of the present application. The general controller may be a microcontroller or any conventional controller, etc. The steps disclosed in the embodiments of the present application may be directly executed by a hardware controller, or may be executed by a combination of hardware and software modules in the controller.
[0160] The memory 602 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs, non-volatile computer executable programs and modules. The memory 602 may include at least one type of storage medium, such as a flash memory, a hard disk, a multimedia card, a card-type memory, a random access memory (English: Random Access Memory, referred to as: RAM), a static random access memory (English: Static Random Access Memory, referred to as: SRAM), a programmable read-only memory (English: Programmable Read Only Memory, referred to as: PROM), a read-only memory (English: Read Only Memory, referred to as: ROM), an electrically erasable programmable read-only memory (English: Electrically Erasable Programmable Read-Only Memory, referred to as: EEPROM), a magnetic memory, a disk, an optical disk, etc. The memory 602 is any other medium that can be used to carry or store a desired program code in the form of an instruction or data structure and can be accessed by a computer, but is not limited thereto. The memory 602 in the embodiment of the present application can also be a circuit or any other device that can realize a storage function, for storing program instructions and / or data.
[0161] By designing and programming the processor 601, for example, the code corresponding to the method introduced in the above embodiment can be solidified into the chip, so that the chip can execute the above method steps when running. How to design and program the processor 601 is a technology well known to those skilled in the art and will not be repeated here.
[0162] Based on the same inventive concept, the embodiment of the present application provides a computer-readable storage medium, and the computer program product includes: computer program code, when the computer program code is run on a computer, the computer executes the method discussed above. Since the principle of solving the problem by the above-mentioned computer-readable storage medium is similar to that of the above-mentioned method, the implementation of the above-mentioned computer-readable storage medium can refer to the implementation of the method, and the repeated parts will not be repeated.
[0163] Based on the same inventive concept, the embodiment of the present application further provides a computer program product, which includes: computer program code, when the computer program code is run on a computer, the computer executes any of the methods discussed above. Since the principle and method of solving the problem by the above computer program product are similar, the implementation of the above computer program product can refer to the implementation of the method, and the repeated parts will not be repeated.
[0164] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0165] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a controller of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the controller of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0166] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0167] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0168] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0169] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data query method, characterized in that: The method is applied to a database server, and the method comprises: Receive data query requests from clients forwarded by the application server; Acquire query results from the database according to the data query request; When the data volume of the query result is greater than a first set threshold, an asynchronous notification message is sent to the client through the application server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and is used to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result; Asynchronous indication information is sent to the asynchronous processing server to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner, and after the processing is completed, the query result is sent to the client based on the polling request initiated by the client.
2. The method according to claim 1, characterized in that Before sending the asynchronous indication information to the asynchronous processing server, the method further includes: Determine whether the data volume is less than a second set threshold; the second set threshold is greater than the first set threshold; When the data volume is less than the second set threshold, generating asynchronous indication information carrying the query result; When the data volume is not less than the second set threshold, the address of the file corresponding to the query result in the database is determined, and asynchronous indication information carrying the address is generated.
3. The method according to claim 1 or 2, characterized in that: The data query request carries the target serial number corresponding to the client, and the polling request initiated by the client carries the target serial number; and the sending of asynchronous indication information to the asynchronous processing server specifically includes: Asynchronous indication information carrying the target serial number is sent to the asynchronous processing server, so that the asynchronous processing server verifies the polling request based on the target serial number.
4. The method according to claim 1 or 2, characterized in that: After obtaining the query result from the database according to the data query request, the method further includes: When the data volume of the query result is not greater than the first set threshold, a synchronization indication message carrying the query result is sent to the application server to instruct the application server to process the data query request in a synchronous processing manner and return the query result to the client after the processing is completed.
5. A data query method, characterized in that: The method is applied to an asynchronous processing server, and the method comprises: Receiving asynchronous indication information sent by a database server; the asynchronous indication information is sent by the database server when it determines that the amount of data in the query result is greater than a first set threshold after receiving a data query request sent by a client; The data query request is processed in an asynchronous processing manner, and after the processing is completed, the query result is sent to the client based on the polling request initiated by the client.
6. The method according to claim 5, characterized in that The sending the query result to the client based on the polling request initiated by the client specifically includes: When it is determined that the asynchronous indication information carries the query result, sending the query result to the client through the redis component based on the polling request; When it is determined that the asynchronous indication information carries a file address, the file corresponding to the to-be-processed data is obtained from the database server according to the file address; and the file is sent to the client based on the polling request.
7. The method according to claim 6, characterized in that Before sending the file to the client based on the polling request, the method further includes: The file obtained from the database server is converted into a file in the target format required by the client.
8. The method according to any one of claims 5 to 7, characterized in that: The asynchronous indication information carries the target serial number corresponding to the client; Before sending the query result to the client based on the polling request initiated by the client, the method further includes: The polling request initiated by the client is verified based on the target serial number.
9. A data query method, characterized in that: The method is applied to a client, and the method comprises: Sending a data query request to a database server through an application server, and receiving an asynchronous notification message returned by the database server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and the asynchronous notification message is sent by the database server when the query result is not less than a first set threshold; Initiate a polling request to the asynchronous processing server based on the asynchronous notification message; Receive the query result returned by the asynchronous processing server.
10. A data query device, characterized in that: The device is applied to a database server, or the device is the database server, and the device includes: A communication unit, used to receive a data query request from a client forwarded by an application server; A processing unit, configured to obtain a query result from a database according to the data query request; The processing unit is further configured to instruct the communication unit to send an asynchronous notification message to the client through the application server when the amount of data in the query result is greater than a first set threshold; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and is configured to instruct the client to initiate a polling request to the asynchronous processing server to obtain the query result; The communication unit is also used to send asynchronous indication information to the asynchronous processing server, which is used to instruct the asynchronous processing server to process the data query request in an asynchronous processing manner, and after the processing is completed, send the query result to the client based on the polling request initiated by the client.
11. The device according to claim 10, characterized in that The processing unit is further used for: Determine whether the data volume is less than a second set threshold; the second set threshold is greater than the first set threshold; When the data volume is less than the second set threshold, generating asynchronous indication information carrying the query result; When the data volume is not less than the second set threshold, the address of the file corresponding to the query result in the database is determined, and asynchronous indication information carrying the address is generated.
12. The device according to claim 10 or 11, characterized in that The data query request carries the target serial number corresponding to the client, and the polling request initiated by the client carries the target serial number; the communication unit is specifically used to: Asynchronous indication information carrying the target serial number is sent to the asynchronous processing server, so that the asynchronous processing server verifies the polling request based on the target serial number.
13. The device according to claim 10 or 11, characterized in that The processing unit is further used for: When the data volume of the query result is not greater than the first set threshold, the communication unit is instructed to send synchronization indication information carrying the query result to the application server, so as to instruct the application server to process the data query request in a synchronous processing manner and return the query result to the client after the processing is completed.
14. A data query device, characterized in that: The device is applied to an asynchronous processing server, or the device is the asynchronous processing server, and the device includes: A communication unit, configured to receive asynchronous indication information sent by a database server; the asynchronous indication information is sent by the database server when it determines that the amount of data in the query result is greater than a first set threshold after receiving a data query request sent by a client; The processing unit is used to process the data query request in an asynchronous processing manner, and after the processing is completed, instruct the communication unit to send the query result to the client based on the polling request initiated by the client.
15. The device according to claim 14, characterized in that The processing unit is specifically used for: When it is determined that the asynchronous indication information carries the query result, instructing the communication unit to send the query result to the client through the redis component based on the polling request; When it is determined that the asynchronous indication information carries a file address, obtaining a file corresponding to the data to be processed from the database server according to the file address; The communication unit is instructed to send the file to the client based on the polling request.
16. The device according to claim 15, characterized in that The processing unit is further used for: The file obtained from the database server is converted into a file in the target format required by the client.
17. The device according to any one of claims 14 to 16, characterized in that: The asynchronous indication information carries the target serial number corresponding to the client; the processing unit is further used to: The polling request initiated by the client is verified based on the target serial number.
18. A data query device, characterized in that: The device is applied to a client, or the device is the client, and the device includes: A communication unit, configured to send a data query request to a database server through an application server, and receive an asynchronous notification message returned by the database server; the asynchronous notification message indicates that the data query request triggers an asynchronous processing mode, and the asynchronous notification message is sent by the database server when the query result is not less than a first set threshold; A processing unit, configured to initiate a polling request to an asynchronous processing server based on the asynchronous notification message; The communication unit is also used to receive the query result returned by the asynchronous processing server.
19. A data query system, characterized in that: The system comprises: The client is used to send data query requests to the database server through the application server; The database server is configured to obtain a query result from the database according to the data query request; when the amount of data in the query result is greater than a first set threshold, send an asynchronous notification message to the client through the application server, and send asynchronous indication information to the asynchronous processing server; The client is further configured to initiate a polling request to the asynchronous processing server based on the asynchronous notification message; The asynchronous processing server is used to process the data query request in an asynchronous processing manner according to the instruction of the asynchronous indication information, and send the query result to the client based on the polling request initiated by the client after the processing is completed.
20. An electronic device, characterized in that: include: A memory for storing program instructions; A processor is used to call the program instructions stored in the memory, and execute the steps included in the method of any one of claims 1-4, claims 5-8 or claim 9 according to the obtained program instructions.
21. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a computer, the computer executes the method of any one of claims 1 to 4, claims 5 to 8, or claim 9.
22. A computer program product, characterized in that The computer program product comprises: a computer program code, and when the computer program code is run on a computer, the computer is enabled to execute the method according to any one of claims 1 to 4, claims 5 to 8 or claim 9.