Data query method and device and related equipment
By pre-querying statements in the database management system to determine the data size and allocate storage space, the problem of download link failure caused by excessive query result data size is solved, achieving more efficient data downloading and user experience.
Patent Information
- Application Number
- CN202410719400.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-27
AI Technical Summary
In the existing technology, the large data scale of query results causes the download link to fail, affecting user experience and work efficiency. Existing solutions limit the download volume but are disadvantageous to big data query users.
In the database management system, the data size of the query results is determined through pre-query statements. If it exceeds the threshold, storage space is allocated and a download link is constructed. The query results are downloaded to the storage space in advance to avoid long-term link occupation and memory overflow.
It effectively avoids download link failure and page memory overflow problems caused by excessive query result data size, and improves user experience and work efficiency.
Smart Images

Figure CN118550947A
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a data query method, device and related equipment. Background Art
[0002] In the prior art, a user can send a query statement to a database management system through an application. The database management system obtains the query result from the database according to the query statement and provides a link to download the query result. The user can download the query result through the application according to the link.
[0003] In actual operation, if the data size of the query result is large, it will take too long to download. According to actual application experience, too long download time will cause the link to fail.
[0004] In order to solve the problem of link failure due to the large data size of the query results, the existing technology avoids the problem of link failure by limiting the download amount. However, such operation causes unnecessary trouble to users with large data query needs, seriously affecting the user experience and work efficiency. Summary of the invention
[0005] In view of this, the purpose of this application is to provide a data query method, device and related equipment, which can solve the technical problem in the prior art that the method may cause link failure due to the large data scale of the query results, which affects the user experience and work efficiency.
[0006] In a first aspect, the present application provides a data query method, which is applied to a database management system, and the method comprises:
[0007] In response to receiving a query request submitted by a user through an application, determining a pre-query statement according to a query statement; the query request includes: the query statement and a request identifier;
[0008] Executing the pre-query statement on a database to determine the data size of a query result corresponding to the query request;
[0009] Determine whether the data size exceeds a size threshold, and if so, allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to a storage address of the storage space;
[0010] Executing the query statement on the database to obtain the query result and downloading the query result to the storage space;
[0011] In response to the download being completed, the download link is sent to the application, so that the user can download the query result through the download link.
[0012] Preferably, executing the pre-query statement on the database to determine the data size of the query result corresponding to the query request includes:
[0013] The pre-query statement is executed on a database to determine the number of columns and rows of data in a query result corresponding to the query request.
[0014] Preferably, the determining whether the data scale exceeds a scale threshold comprises:
[0015] Determine whether the number of rows of data in the query result exceeds a first threshold; determine whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
[0016] Preferably, if the number exceeds, allocating storage space for the query result based on the request identifier and constructing a download link corresponding to the request identifier for the query result according to the storage address of the storage space, comprises:
[0017] If the number of rows of data in the query result exceeds a first threshold or the product of the number of columns and the number of rows of data in the query result exceeds a second threshold, storage space is allocated for the query result based on the request identifier and a download link corresponding to the request identifier is constructed for the query result according to the storage address of the storage space.
[0018] In a second aspect, the present application provides a data query device, which is applied to a database management system, and the device includes: a request module, an execution module, a judgment module and a message module;
[0019] The request module is used to determine the pre-query statement according to the query statement in response to receiving a query request submitted by the user through the application; the query request includes: the query statement and the request identifier;
[0020] The execution module is used to execute the pre-query statement on the database to determine the data size of the query result corresponding to the query request;
[0021] The judging module is configured to judge whether the data size exceeds a size threshold, and if so, allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to a storage address of the storage space;
[0022] The execution module is further used to execute the query statement on the database to obtain the query result and download the query result to the storage space;
[0023] The message module is used to send the download link to the application in response to the download completion, so that the user can download the query result through the download link.
[0024] Preferably, the execution module is further used to execute the pre-query statement on the database to determine the number of columns and rows of data in the query result corresponding to the query request.
[0025] Preferably, the judgment module is further used to judge whether the number of rows of data in the query result exceeds a first threshold; and judge whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
[0026] In a third aspect, the present application provides an electronic device, comprising a processor and a memory, wherein the memory is used to store software programs, and the processor enables the electronic device to implement the above-mentioned method by running or executing the software program stored in the memory.
[0027] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store program codes executed by a processor, wherein the program codes include methods for implementing the above-mentioned method.
[0028] In a fifth aspect, the present application provides a computer program product, including a program code, so that when a computer runs the computer program product, the computer executes the above method.
[0029] Beneficial effects:
[0030] In summary, the present application provides a data query method, comprising: in response to receiving a query request submitted by a user through an application, determining a pre-query statement according to the query statement; the query request comprises: a query statement, a request identifier; executing the pre-query statement on a database to determine the data scale of a query result corresponding to the query request; judging whether the data scale exceeds a scale threshold, if so, allocating storage space for the query result based on the request identifier and constructing a download link corresponding to the request identifier for the query result according to the storage address of the storage space; executing the query statement on the database to obtain the query result and downloading the query result to the storage space; in response to the download being completed, sending the download link to the application so that the user can download the query result through the download link.
[0031] The present application determines the data scale of the query result corresponding to the query statement by setting a pre-query statement and judges the size of the data scale based on a scale threshold. If the judgment result shows that the data scale exceeds the scale threshold, the query result is pre-downloaded to the storage space, and then a download link is constructed for the storage space, so that the user can download the query result from the storage space of the database management system according to the download link, avoiding the problem that if the data scale of the query result is too large, the download link will be occupied for a long time and further cause the link to become invalid. In addition, it can also avoid the problem of page memory overflow caused by the excessive data scale of the query result. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0033] Figure 1 A schematic diagram of a flow chart of a data query method provided in an embodiment of the present application;
[0034] Figure 2 Another flowchart of the data query method provided in the embodiment of the present application;
[0035] Figure 3 A schematic diagram of the structure of a data query device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0036] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present application.
[0037] First, the present application provides an embodiment of a data query method, which is applied to a database management system, such as Figure 1 As shown, Figure 1 A flow chart of a data query method provided in an embodiment of the present application, the method comprising:
[0038] S110: In response to receiving a query request submitted by a user through an application, determining a pre-query statement according to the query statement.
[0039] The query request includes: a query statement and a request identifier.
[0040] Specifically, with the continuous development of IT technology, most applications are turning towards lightweight, and database link tools are one of them. Compared with traditional installed applications, database link tools can be used as long as the browser supports it; in addition, database link tools also have the ability to update and take effect in real time, and the logic is all in the database operating system, and refreshing the page will take effect; in addition, database link tools also have good interactivity. In addition, the user interactivity, animation, form, real-time communication and other capabilities of current applications can bring a good user experience; in addition, database link tools also have better security, and Web applications have better security restriction capabilities. All data request services can obtain relevant information through the database management system to ensure that users' high-risk operations are discovered in a timely manner. The embodiment of this application is based on the database management system and implemented by the database link tool installed in the database management system.
[0041] The database management system in the embodiment of the present application is provided with a query result storage area, which is used to pre-store query results corresponding to the user's query request and meeting the trigger condition. The setting of the trigger condition is detailed in the subsequent content.
[0042] In the embodiment of the present application, the query statement is a SQL query statement.
[0043] When the database management system receives a query request submitted by a user in an application, the query request includes a query statement and a request identifier. However, the database management system will not execute the query statement immediately, but will generate a pre-query statement based on the query statement.
[0044] The purpose of setting a pre-query statement is to determine the data size of the query result corresponding to the query request in advance before executing the query statement.
[0045] In one implementation, the data size of the query result is the number of columns and rows of data in the query result. S110 includes (1), as follows:
[0046] (1) Based on the table name and field name of the data table in the query statement, determine the pre-query statement used to determine the number of columns and rows of data in the query result.
[0047] Specifically, in actual operation, the pre-query statement is determined according to the table name and field name of the data table in the query statement. The pre-query statement is used to determine the number of columns and rows of data in the query result. In the embodiment of the present application, two pre-query statements can usually be generated according to each query statement, one pre-query statement is used to determine the number of rows of data in the query result, and the other is used to determine the number of columns of data in the query result.
[0048] For example, when the query statement is "SELECT * from tableA", the corresponding pre-query statement is as follows:
[0049] "columnNum
[0050] SELECT COUNT(*)
[0051] FROM INFORMATION_SCHEMA.COLUMNS
[0052] WHERE TABLE_NAME='tableA'AND TABLE_SCHEMA='dbname';"
[0053] The statement used to query the number of rows in the prepared query statement is as follows:
[0054] "lineNum
[0055] select count(1)from tableA".
[0056] S120: Execute the pre-query statement on the database to determine the data size of the query result corresponding to the query request.
[0057] Specifically, after the database management system generates the pre-query statement, it will execute the pre-query statement and determine the data size of the query result through the database. The purpose of determining the data size of the query result is to judge the size of the data size of the query result later, and to determine whether the data size of the query result may cause the download link between the application and the database to fail.
[0058] S130: Determine whether the data size exceeds the size threshold. If so, allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to the storage address of the storage space.
[0059] Specifically, after the database management system determines the data size of the query result, in order to prevent the query result from being too large, causing the download link between the application and the database to be occupied for a long time and causing the link to fail, the database management system will judge the size of the data size of the query result.
[0060] In actual operation, the database management system can determine whether the data size of the query result has the risk of causing the download link between the application and the database to be occupied for a long time and further cause the link to fail by judging whether the number of columns and rows in the query result exceeds the corresponding size threshold. The size threshold is determined according to actual needs.
[0061] In one implementation, Figure 2 As shown, Figure 2 Another flowchart of the data query method provided in the embodiment of the present application, S130 includes S1301 to S1303, the details of which are as follows:
[0062] S1301: Determine whether the number of rows of data in the query result exceeds a first threshold; determine whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
[0063] Specifically, in the embodiment of the present application, the data size of the query result is the number of columns and rows of the data in the query result. In actual operation, the first threshold for determining the number of rows of data in the query result can be set to 100, and the second threshold for determining the product of the number of columns and rows of data in the query result can be set to 10000.
[0064] If the number of columns in the query result data is greater than 100 or the product of the number of columns and the number of rows in the query result data is greater than 10,000, it is believed that the data scale of the query result may cause the download link between the application and the database to be occupied for a long time, resulting in link failure. Therefore, a link for downloading query results from the database cannot be directly built for the database and application.
[0065] S1302: If the number of rows of data in the query result exceeds a first threshold or the product of the number of columns and the number of rows of data in the query result exceeds a second threshold, storage space is allocated for the query result based on the request identifier and a download link corresponding to the request identifier is constructed for the query result according to the storage address of the storage space.
[0066] Specifically, if the judgment result shows that the data size of the query result may cause the download link between the application and the database to become invalid, in response to the judgment result that the data size of the query result may cause the download link between the application and the database to become invalid, the database management system will allocate storage space for the query result in the query result storage area based on the request identifier corresponding to the query request and construct a download link with the application based on the storage address of the storage space through a database link tool.
[0067] It should be noted that "in response to the determination result that the data size of the query result may cause the download link between the application and the database to become invalid" is the "trigger condition" mentioned above.
[0068] S1303: If the number of rows of data in the query result does not exceed the first threshold and the product of the number of columns and the number of rows of data in the query result does not exceed the second threshold, construct a download link for directly downloading the query result from the database based on the request identifier.
[0069] Specifically, if the number of columns of data in the query result is not greater than 100 and the product of the number of columns and the number of rows of data in the query result is not greater than 10,000, it is considered that the data scale of the query result will not cause the download link between the application and the database to be occupied for a long time, resulting in link failure. Therefore, a download link for downloading query results from the database can be directly constructed for the database and the application through the database link tool and the download link can be sent to the application, allowing the user to download the query results directly from the database through the download link.
[0070] S140: Execute the query statement on the database to obtain the query result and download the query result to the storage space.
[0071] Specifically, after the storage space is allocated, the database management system downloads the query result corresponding to the request identifier into the storage space.
[0072] S150: In response to the download being completed, a download link is sent to the application program, so that the user can download the query result through the download link.
[0073] Specifically, after the download is completed, the database management system will push a message to the application or send an email to the user. The message or email includes a download link newly constructed by the database management system. The user can download the query result corresponding to the query request through the download link.
[0074] In summary, the embodiment of the present application determines the data scale of the query result corresponding to the query statement by determining the pre-query statement and judges the size of the data scale based on the scale threshold. If the judgment result shows that the data scale exceeds the scale threshold, the query result is pre-downloaded to the storage space, and then a download link is constructed for the storage space, so that the user can download the query result from the storage space of the database management system according to the download link, avoiding the problem that if the data scale of the query result is too large, the download link will be occupied for a long time and further cause the link to become invalid. In addition, it can also avoid the problem of page memory overflow caused by the excessive data scale of the query result.
[0075] Second, the present application provides a data query device, which is applied to a database management system, such as Figure 3 As shown, Figure 3 This is a structural diagram of a data query device provided in an embodiment of the present application, wherein the device includes: a request module 310, an execution module 320, a judgment module 330 and a message module 340.
[0076] The request module 310 is used to determine the pre-query statement according to the query statement in response to receiving the query request submitted by the user through the application; the query request includes: the query statement and the request identifier;
[0077] An execution module 320 is used to execute a pre-query statement on a database to determine a data size of a query result corresponding to the query request;
[0078] A determination module 330 is used to determine whether the data size exceeds a size threshold, and if so, allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to a storage address of the storage space;
[0079] The execution module 320 is further used to execute the query statement on the database to obtain the query result and download the query result to the storage space;
[0080] The message module 340 is used to send a download link to the application in response to the download completion, so that the user can download the query result through the download link.
[0081] In one implementation, the execution module 320 is further configured to execute a pre-query statement on a database to determine the number of columns and rows of data in a query result corresponding to the query request.
[0082] In one implementation, the judgment module 330 is further used to judge whether the number of rows of data in the query result exceeds a first threshold; and judge whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
[0083] In one embodiment, the judgment module 330 is also used to allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to the storage address of the storage space if the number of rows of data in the query result exceeds a first threshold or the product of the number of columns and rows of data in the query result exceeds a second threshold.
[0084] Third, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements steps S110 to S150 provided in the above embodiment when executing the computer program.
[0085] Fourthly, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, steps S110 to S150 of the above embodiment are executed.
[0086] Fifth, the computer program product provided in the present application includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the method in the previous method embodiment. The specific implementation can refer to steps S110 to S150 of the method embodiment, which will not be repeated here.
[0087] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of devices or units can be electrical, mechanical or other forms.
[0088] In addition, the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0089] Furthermore, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist independently, or two or more modules may be integrated to form an independent part.
[0090] It should be noted that if the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can essentially be embodied in the form of a software product, or the part that contributes to the prior art or the part of the technical solution. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM) random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0091] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.
[0092] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A data query method, characterized in that: Applied to a database management system, the method comprises: In response to receiving a query request submitted by a user through an application, determining a pre-query statement according to a query statement; the query request includes: the query statement and a request identifier; Executing the pre-query statement on a database to determine the data size of a query result corresponding to the query request; Determining whether the data size exceeds a size threshold, and if so, allocating storage space for the query result based on the request identifier and constructing a download link corresponding to the request identifier for the query result according to a storage address of the storage space; Executing the query statement on the database to obtain the query result and downloading the query result to the storage space; In response to the download being completed, the download link is sent to the application, so that the user can download the query result through the download link.
2. The method according to claim 1, characterized in that The executing the pre-query statement on the database to determine the data size of the query result corresponding to the query request includes: The pre-query statement is executed on a database to determine the number of columns and rows of data in a query result corresponding to the query request.
3. The method according to claim 2, characterized in that The determining whether the data size exceeds a size threshold includes: Determine whether the number of rows of data in the query result exceeds a first threshold; determine whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
4. The method according to claim 3, characterized in that If the number exceeds the limit, allocating storage space for the query result based on the request identifier and constructing a download link corresponding to the request identifier for the query result according to the storage address of the storage space, including: If the number of rows of data in the query result exceeds a first threshold or the product of the number of columns and the number of rows of data in the query result exceeds a second threshold, storage space is allocated for the query result based on the request identifier and a download link corresponding to the request identifier is constructed for the query result according to the storage address of the storage space.
5. A data query device, characterized in that: Applied to a database management system, the device comprises: a request module, an execution module, a judgment module and a message module; The request module is used to determine the pre-query statement according to the query statement in response to receiving a query request submitted by the user through the application; the query request includes: the query statement and the request identifier; The execution module is used to execute the pre-query statement on the database to determine the data size of the query result corresponding to the query request; The judging module is configured to judge whether the data size exceeds a size threshold, and if so, allocate storage space for the query result based on the request identifier and construct a download link corresponding to the request identifier for the query result according to a storage address of the storage space; The execution module is further used to execute the query statement on the database to obtain the query result and download the query result to the storage space; The message module is used to send the download link to the application in response to the download completion, so that the user can download the query result through the download link.
6. The device according to claim 5, characterized in that The execution module is further used to execute the pre-query statement on the database to determine the number of columns and rows of data in the query result corresponding to the query request.
7. The device according to claim 6, characterized in that The judgment module is further used to judge whether the number of rows of data in the query result exceeds a first threshold; and judge whether the product of the number of columns and the number of rows of data in the query result exceeds a second threshold.
8. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory is used to store a software program, and the processor runs or executes the software program stored in the memory so that the electronic device implements the method according to any one of claims 1 to 4.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store program codes executed by a processor, wherein the program codes include instructions for implementing the method according to any one of claims 1 to 4.
10. A computer program product, characterized in that The computer program product comprises program codes, and when a computer runs the computer program product, the computer executes the method according to any one of claims 1 to 4.
