Query method, device, computer equipment, storage medium and program product
By using the accelerated query component in the query engine to directly obtain query results from the in-memory database, the problems of high computing resource consumption and slow response in the existing technology are solved, and faster query response speed is achieved.
Patent Information
- Application Number
- CN202111514593.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-13
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2041-12-13
AI Technical Summary
In the existing technology, query engines such as Hive and Presto need to pull data into memory for association calculation and projection filtering when querying Hive tables online, resulting in high computing resource consumption and slow query response.
By receiving the query request from the terminal, it is determined whether the number of target forms is less than or equal to the preset value. If so, the accelerated query component is used to directly obtain the query results from the target memory database in the server cluster, avoiding pulling data into the memory for association calculation and projection filtering.
This reduces the number of file scanning IO times and computing resource consumption, thereby improving query response speed.
Smart Images

Figure CN114185924B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology and can be used in the field of Internet finance or other related fields, and in particular to a query method, apparatus, computer equipment, storage medium and program product. Background Art
[0002] With the development of technology, massive amounts of digital data are generated daily in various social activities. Hadoop clusters have become a mainstay for storing and analyzing this massive amount of data. Consequently, effective data analysis to rapidly inform company decisions for business development has become the guiding principle of current data analysis.
[0003] In related technologies, data queries are typically performed using query engines such as Hive and Presto within a Hadoop cluster. However, these engines support the standard JDBC (Java Data Base Connectivity) protocol. When querying Hive tables online, they must pull data into memory for join calculations, projections, and filtering to complete the query.
[0004] However, the query process in the related art has the problems of high consumption of computing resources and slow query response. Summary of the Invention
[0005] Based on this, it is necessary to provide a query method, apparatus, computer equipment, computer-readable storage medium and computer program product that can speed up the query process in order to address the above technical issues.
[0006] In a first aspect, the present application provides a query method, the method comprising:
[0007] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0008] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0009] Send the query results to the terminal.
[0010] In one embodiment, it further includes:
[0011] If the number of target forms is greater than the preset value, the query result corresponding to the query request is obtained through the original query component; the original query component represents a component that obtains the scan result of the target form in the query request through cold start scanning, and obtains the query result after processing the scan result.
[0012] In one embodiment, obtaining a query result corresponding to a query request through a preset accelerated query component includes:
[0013] If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received.
[0014] In one embodiment, the query request includes the location of the target form to be queried, and the preset sending condition includes at least one of the following:
[0015] The location of the target form is in the target in-memory database in the server cluster;
[0016] The target form is not located in the target memory database in the server cluster, the startup status of the target memory database is started, and the data volume of the target form meets the preset first capacity condition.
[0017] In one embodiment, the data volume of the target form satisfies a preset first capacity condition, including:
[0018] The data volume of the target form is within the standard threshold range and is less than or equal to the memory capacity of the target in-memory database.
[0019] In one embodiment, the method further comprises:
[0020] If the target form is not located in the target memory database in the server cluster, and the target memory database is not started, start the target memory database.
[0021] The operation of starting the target in-memory database includes: applying for the target container in the resource queue of the target user;
[0022] Start the target in-memory database in the target container.
[0023] In one embodiment, the method further comprises:
[0024] If the target form is not located in the target memory database in the server cluster, the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then perform the memory adjustment operation;
[0025] The memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
[0026] In one embodiment, the second capacity condition includes:
[0027] The data volume of the target form is within the standard threshold range and is greater than the remaining memory capacity of the in-memory database.
[0028] In a second aspect, the present application further provides a query device, comprising:
[0029] The information receiving module is used to receive a query request sent by the terminal; the query request includes the number of target forms to be queried;
[0030] A result acquisition module is used to obtain the query result corresponding to the query request through a preset accelerated query component if the number of target forms is less than or equal to a preset value; the accelerated query component is a component that obtains the query result from the target in-memory database in the server cluster;
[0031] The result sending module is used to send the query results to the terminal.
[0032] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0033] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0034] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0035] Send the query results to the terminal.
[0036] In a fourth aspect, the present application further provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:
[0037] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0038] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0039] Send the query results to the terminal.
[0040] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the following steps:
[0041] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0042] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0043] Send the query results to the terminal.
[0044] The query method, apparatus, computer device, storage medium, and program product described above compare the number of target forms in a query request sent by a receiving terminal with a preset value. If the number of target forms is less than or equal to the preset value, the query request is processed by obtaining the query result corresponding to the query request through an accelerated query component. This accelerated query component is a component that obtains the query result from a target in-memory database in a server cluster. This method eliminates the need to pull data into memory for correlation calculation and projection filtering when obtaining the query result. Instead, the accelerated query component directly obtains the query result from the in-memory database. This reduces the number of file scan I / O operations and computing resource consumption, thereby improving query response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 A diagram of an application environment of a query method in one embodiment;
[0046] Figure 2 1 is a flow chart of a query method in one embodiment;
[0047] Figure 3 A system architecture block diagram of a query device in one embodiment;
[0048] Figure 4 A logical diagram of a query method in another embodiment;
[0049] Figure 5 is a structural block diagram of a query device in one embodiment;
[0050] Figure 6 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0051] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0052] The query method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or it can be placed on the cloud or other network servers. The server 104 is used for data storage. Among them, the terminal 102 can be but is not limited to various personal computers, laptops, smart phones, tablets, Internet of Things devices and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart car-mounted devices, etc. Portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented as an independent server or a server cluster consisting of multiple servers.
[0053] Based on the above application environment, for ease of explanation, the carrier implementing the query method will be represented below as a query program. The user enters a query request into terminal 102, and terminal 102 sends the query request to the query program. The query program communicates with server 104 to retrieve the corresponding query results from server 104 based on the query request. This application does not limit the specific location of the query program; it can be located in terminal 102, in server 104, or in a server layer added between terminal 102 and server 104 to host the query program. However, the query program's execution logic must be located after the user enters the query request and before the query results corresponding to the query request are retrieved.
[0054] In one embodiment, Figure 2 As shown, a query method is provided, which is applied to Figure 2 Taking this as an example, the following steps are included:
[0055] Step 202: Receive a query request sent by a terminal; the query request includes the number of target forms to be queried.
[0056] The query request can be a query request statement used for data query, such as an SQL statement. For another example, the query request statement can be written by the user based on actual needs, or can be transmitted from other devices, or called from a database. The embodiments of the present application do not limit the query request. By analyzing and sorting according to actual needs, the names of the various forms where the target query data is located, i.e., the names of the target forms, can be obtained for use in writing the query request statement. By analyzing and processing the form names in the query request statement, the number of target forms can be obtained.
[0057] A terminal can be understood as any client capable of performing queries, i.e., a query client. For example, a query client corresponding to the present method can be installed on the user's terminal business system to receive user input query requests. The query client can implement the standard JDBC protocol and is a standard JDBC driver.
[0058] Specifically, a user query client receives a query request statement input based on actual needs. The query client then sends the query request statement to a query program, which then receives the corresponding query request statement. The query program then extracts the names of the target forms from the query request statement and obtains the number of target forms based on the names of the target forms. This application does not limit the language or format of the query request statement corresponding to the query request; it is sufficient to implement the function of querying information from the database based on actual needs.
[0059] In a specific implementation, taking an SQL query as an example, if the user's actual requirement is "find the course numbers and names of courses with 3 credits," the user enters SQL query statement 1, "select cno, cname from courses where credit = 3," and instructs the query client to send this query statement 1 to the query program via the standard JDBC protocol. The query program receives query statement 1, extracts the name of the target form, courses, from query statement 1, and calculates the number of target forms, 1, based on the name of each target form. The query client is a program package installed in the user's business system.
[0060] Step 204 : If the number of target forms is a preset value, a query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component refers to a component that obtains query results from a target memory database in the server cluster.
[0061] Among them, the preset value is a value set according to the ability of the target memory database to process the data table. For example, the preset value can be 1, or, in actual applications, the preset value can be set to other values, such as 2, 3, etc., according to the ability of the target memory database to calculate the number of forms. The embodiment of the present application does not limit the size of the preset value and can be adaptively modified.
[0062] The accelerated query component is a query connection written for this application based on the number of target forms to meet the processing capacity of the target memory database. The query connection is used for data extraction and transmission. It should be noted that the other end of the connection position of the accelerated query component is the target user's memory database in the data storage area, that is, the target memory library. Preferably, the data storage method of the server 104 is to store the data based on the method corresponding to the Hadoop cluster, and use data processing engines such as Hive / Spark to complete the data batch processing logic, and store the corresponding processing results in the Hive table. The target memory database is a memory database running in a Yarn Container, and the Yarn Container belongs to the target user.
[0063] Specifically, the query program compares the number of target forms included in the query request statement with a preset value. If the number of target forms is less than or equal to the preset value, the query program communicates with the server cluster of the data storage through the acceleration query component, obtains the location information of the target form from it to locate the target memory database of the target user in the server cluster where the target form in the query statement is located, sends a query request to the target memory database of the target user in the server cluster, and receives the query result returned by the target memory database returned by the target user.
[0064] Step 206: Send the query result to the terminal.
[0065] In specific implementations, the accelerated query component sends query request statement 1 to the target user's in-memory database within the data storage area to execute the corresponding query logic to obtain the corresponding query results, and then returns the query results to the query program. The target user is determined by the user's identity verification performed when logging into the query client. This can determine the user's identity and, therefore, the target user within the data storage area being queried.
[0066] The query method, apparatus, computer device, storage medium, and program product described above compare the number of target forms in a query request sent by a receiving terminal with a preset value. If the number of target forms is less than or equal to the preset value, the query request is processed by obtaining the query result corresponding to the query request through an accelerated query component. This accelerated query component is a component that obtains the query result from a target in-memory database in a server cluster. This method eliminates the need to pull data into memory for correlation calculation and projection filtering when obtaining the query result. Instead, the accelerated query component directly obtains the query result from the in-memory database. This reduces the number of file scan I / O operations and computing resource consumption, thereby improving query response speed.
[0067] In one embodiment, if the number of target forms is greater than a preset value, the query result corresponding to the query request is obtained through the original query component; the original query component represents a component that obtains the scan result of the target form in the query request through a cold start scan, and obtains the query result after processing the scan result.
[0068] Specifically, taking the preset value of 1 as an example, that is, the number of target forms is greater than 1, for example, when the number of target forms is 2, 3, 4, or any other case greater than 1, the terminal controls the original query component to obtain the scanning result of the target form in the query request through cold start scanning, and obtains the query result after processing the scanning result.
[0069] In a specific implementation, let's take query statement 2 as an example. The query statement targets two tables. The query program queries query statement 2 using the original query component, such as Hive or Presto. Hive or Presto performs a cold start scan to obtain the scan results for the target tables "students, enrolls" in query statement 2. These scan results are then processed to obtain the query results. The corresponding query logic is then executed to obtain the corresponding query results, which are then returned to the query program. Query statement 2 is: select sname, bplace, grade from students, enrolls where students.sno = enrolls.sno and bplace in <'Shanxi', 'Hebei'> and grade > 90.
[0070] In this embodiment, the query program makes a judgment based on whether the number of target forms in the query request sent by the receiving terminal is 1. If the number of target forms is not 1, the query result corresponding to the query request is obtained through the original query component, so that the query capability of this query method is not only to accelerate the query of the number of forms that the query component can process, but also to include the query capability corresponding to the original query component.
[0071] In one embodiment, obtaining a query result corresponding to a query request through a preset accelerated query component includes:
[0072] If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received.
[0073] The preset sending condition is a condition for determining whether the query request statement is queried through the accelerated query component, and is preset according to the memory capacity of the target user.
[0074] Specifically, the query program communicates with the server cluster where the data is stored to obtain relevant information about the target form and determine whether the target form meets the preset sending conditions. If the target form meets the preset sending conditions, the query program sends a query request to the target user in the server cluster through the accelerated query component and receives the query results returned by the target user. If the target form does not meet the preset sending conditions, the query program sends a query request to the server cluster through the original query component and receives the returned query results.
[0075] In this embodiment, the use scope of the accelerated query component is further clarified by pre-set sending conditions, which can reduce the error rate of the system.
[0076] In one embodiment, the query request includes the location of a target form to be queried, and the predetermined sending conditions include at least one of the following: the target form is located in a target in-memory database in the server cluster; the target form is not located in the target in-memory database in the server cluster, the target in-memory database is in an enabled state, and the data volume of the target form meets a predetermined first capacity condition.
[0077] The target form location is the address of the target form in the data storage system. A server cluster is one implementation of a data storage system. The target in-memory database is a memory database running in a Yarn Container that belongs to the target user.
[0078] Specifically, if the query program determines that the target query component is an accelerated query component, it communicates with the server cluster storing the data to obtain the location information of the target form and determine whether the target form is located in the target user's target in-memory database within the server cluster. If the target form is located in the target user's target in-memory database within the server cluster, the query program determines that the target form meets the preset sending conditions. The query program then sends a query request to the target user's target in-memory database within the server cluster through the accelerated query component and receives the query results returned by the target user's target in-memory database.
[0079] The preset first capacity condition is a limiting condition related to the target form.
[0080] Specifically, if the query program determines that the target query component is an accelerated query component, it communicates with the server cluster storing the data to obtain the location information of the target form and determine whether the target form is located in the target memory database of the target user in the server cluster. If the target form is not located in the target memory database of the target user in the server cluster, it determines whether the target memory database is started. If the target memory database is started, the query program continues to determine whether the data volume of the target form meets the preset first capacity condition. If the data volume of the target form meets the preset first capacity condition, the query program deems that the target form meets the preset sending condition. The query program sends a query request to the target memory database of the target user in the server cluster through the accelerated query component and receives the query result returned by the target memory database of the target user.
[0081] In this embodiment, the use scope of the accelerated query component is further clarified through the preset sending conditions, which can reduce the error rate of the system.
[0082] In one embodiment, the data volume of the target form meets a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database.
[0083] The standard threshold range is determined based on the capacity of the memory database of at least one Yarn Container in the server cluster. This embodiment does not limit the standard threshold range. Based on specific needs, the standard threshold range can optionally be 0 to the maximum storage capacity of the memory data database of the Yarn Container.
[0084] Specifically, if the target form's data volume falls within a standard threshold range and is less than or equal to the target in-memory database's memory capacity, the query program determines that the target form's data volume satisfies a preset first capacity condition. If the target form's data volume falls outside the standard threshold range, the query program changes the target query component to the original query component, sends a query request to the server cluster through the original query component, and receives the returned query results.
[0085] In this embodiment, the use scope of the accelerated query component is further clarified through the data volume of the target form, which can reduce the error rate of the system.
[0086] In one embodiment, if the location of the target form is not located in the target memory database in the server cluster and the startup status of the target memory database is not started, the target memory database startup operation is executed; the target memory database startup operation includes: applying for a target container in the resource queue of the target user; and starting the target memory database in the target container.
[0087] The resource queue is the resource allocation and scheduling queue of the server cluster. The target container is a resource container allocated by the resource queue of the server cluster. It contains CPU and memory resources and is used to execute computing tasks.
[0088] Specifically, if the target form is not located in the target in-memory database in the server cluster and the target in-memory database is not started, the query program executes an operation to start the target in-memory database. This operation includes: applying for a target container in the target user's resource queue and starting the target in-memory database in the target container. Once the target in-memory database is started, the query program then executes a step to determine whether the data volume of the target form meets a preset first capacity condition.
[0089] In this embodiment, the query program applies for a target container in the resource queue of the target user and starts the target memory database in the target container to meet the use conditions of the accelerated query component, thereby obtaining the query result corresponding to the query request through the accelerated query component. When performing data query, it does not need to pull the data into the memory for association calculation and projection filtering, which reduces file scanning IO and the consumption of computing resources, thereby speeding up the query response.
[0090] In one embodiment, it also includes: if the location of the target form is not located in the target memory database in the server cluster, and the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then perform a memory adjustment operation; the memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
[0091] The second capacity condition is a limiting condition related to the target form.
[0092] Specifically, if the target form is not located in the target memory database in the server cluster and the memory database is in the enabled state, the query program determines whether the target form's data volume satisfies a preset second capacity condition. If the target form's data volume satisfies the preset second capacity condition, the query program performs a memory adjustment operation. The memory adjustment operation includes: the query program sequentially deletes the forms with the fewest accesses currently loaded in the memory database according to the principle of least access, until the remaining memory capacity of the memory database is greater than or equal to the target form's data volume, at which point the query program loads the target form into the target memory database. The query program then sends a query request to the target user's target memory database in the server cluster via the accelerated query component, and receives the query results returned by the target user from the target memory database.
[0093] In this embodiment, the query program uses the principle of minimum access to make the target form meet the preset second capacity condition and meet the use conditions of the accelerated query component, thereby obtaining the query results corresponding to the query request through the accelerated query component. When performing data queries, it does not need to pull data into the memory for association calculation and projection filtering, which reduces file scanning IO and the consumption of computing resources, thereby speeding up the query response.
[0094] In one embodiment, the second capacity condition includes: the data volume of the target form is within a standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
[0095] Specifically, if the data volume of the target form is within the standard threshold range and the data volume of the target form is greater than the memory capacity of the target memory database, the query program determines that the data volume of the target form meets the preset second capacity condition and performs a memory adjustment operation.
[0096] In this embodiment, the use scope of the accelerated query component is further clarified through the relevant information of the data volume of the target form, which can reduce the error rate of the system.
[0097] like Figure 3 As shown, a specific embodiment is used to illustrate that the implementation of this query method includes: QueryClient (query client), QuerySever (query server) and Hadoop cluster.
[0098] The Query Client is a user-installed program package in Business System A. It implements the Driver interface portion of the JDBC (Java Database Connectivity) interface and communicates with the Query Server. The Query Client in this application is used in the same manner as other versions, implementing and transmitting query requests using SQL (Structured Query Language).
[0099] Figure 3 The Query Sever in the implementation implements the Server part of the JDBC interface, and also includes Hive / Presto Connection (connection component) and MemoryDB Connection (connection component). In this embodiment, the Query Sever is placed separately in the query server.
[0100] Figure 3 The Hadoop cluster is used for data storage and processing and is located in the Hadoop cluster server. The Hadoop cluster server includes Hive / Presto JDBC Sever (Hive / Presto's Java database connection server) and tenants. Among them, Hive / Presto JDBC Sever is used to transmit data and execute corresponding data processing logic with the Hive / Presto Connection (connection component) of the query server. Tenants can be understood as many users who want to use the Hadoop cluster server. The Hadoop cluster server allocates corresponding resources to these users. The resources of each user can be abstracted as Figure 3 Each tenant in the Hadoop cluster requires corresponding permissions for resource scheduling. When a user logs in to the business system, identity authentication information is triggered. When the system confirms the identity information, it determines the permissions the user has. This permission information includes the tenants allowed to schedule resources. Each tenant includes stored data information, Yarn Container (Yarn resource container), and MemoryDB (in-memory database). Among them, Yarn Container is allocated by the resource scheduler in the Hadoop cluster. YarnContainer contains CPU and memory resources for executing computing tasks.
[0101] based on Figure 3 Query Client, Query Sever and Hadoop cluster in Figure 4 Take Query as an example to illustrate the implementation process of the specific query method.
[0102] User login Figure 3 When business system A in the process of identity authentication is in progress, business system A confirms that it can Figure 3 Tenant A has the operation permission. After logging into business system A, the user enters SQL query request statement 1 into the Query Client of business system A according to business requirements. The Query Client of business system A transmits SQL query request statement 1 to the Query Server. Figure 4 As shown, the Query Server receives SQL query statement 1 from the Query Client and analyzes it to determine whether it is a single-table query. If the Query Server determines that SQL query statement 1 is not a single-table query, it sends SQL query statement 1 to the Hive / Presto Connection in the Query Server. The Hive / Presto Connection executes the query in SQL query statement 1 through the Hive / PrestoJDBC Server in the Hadoop cluster, obtains a ResultSet, and feeds this ResultSet back to the user step by step.
[0103] If the Query Sever determines that SQL query request statement 1 is a query on a single table, the Query Sever determines whether SQL query request statement 1 is in the corresponding tenant's MemoryDB. If SQL query request statement 1 is in the corresponding tenant's MemoryDB, the Query Sever sends SQL query request statement 1 to the MemoryDBConnection in the Query Sever. The MemoryDB Connection executes the query request in SQL query request statement 1 through the MemoryDB in the Hadoop cluster, obtains the ResultSet result set, and feeds the ResultSet result set back to the user step by step.
[0104] If SQL query request statement 1 is not in the corresponding tenant's MemoryDB, the Query Sever determines whether the corresponding tenant's MemoryDB has been started. If the corresponding tenant's MemoryDB has been started, the Query Sever determines whether the data volume of the query table of SQL query request statement 1 is within the threshold.
[0105] If the corresponding tenant's MemoryDB is not started, the Query Sever applies for a Container in the corresponding tenant's YARN resource queue, starts MemoryDB in the Container, and then continues to determine whether the data volume of the query table in SQL query request statement 1 is within the sub-threshold.
[0106] If the Query Sever determines that the data volume of the query table of SQL query request statement 1 is not within the threshold, the Query Sever sends SQL query request statement 1 to the Hive / Presto Connection in the Query Sever. The Hive / Presto Connection executes the query request in SQL query request statement 1 through the Hive / Presto JDBC Sever in the Hadoop cluster, obtains the ResultSet result set, and feeds the ResultSet result set back to the user step by step.
[0107] If the Query Server determines that the data volume in the query table for SQL query statement 1 is within the threshold, it determines whether MemoryDB can accommodate the query table. If so, it loads the table into MemoryDB. The Query Server sends SQL query statement 1 to the MemoryDB Connection within the Query Server. The MemoryDB Connection executes the query in SQL query statement 1 through MemoryDB in the Hadoop cluster, obtains the ResultSet, and then feeds this ResultSet back to the user in a tiered manner.
[0108] If MemoryDB cannot load the query table for SQL query request statement 1, Query Sever removes data tables from MemoryDB according to the least accessed first elimination principle until memory space is freed up for the query table that can load SQL query request statement 1, and then loads the query table into MemoryDB.
[0109] In the aforementioned query method, the query program compares the number of target forms in a query request sent by a receiving terminal with a preset value. If the number of target forms is less than or equal to the preset value, the query request is processed by obtaining the query result corresponding to the query request through an accelerated query component. This accelerated query component is a component that obtains query results from a target in-memory database in a server cluster. This method eliminates the need to pull data into memory for correlation calculations and projection filtering when obtaining query results. Instead, the accelerated query component directly retrieves the query results from the in-memory database. This reduces the number of file scan I / O operations and computing resource consumption, thereby improving query response speed.
[0110] It should be understood that, although the various steps in the flowcharts involved in the various embodiments described above are displayed in sequence according to the instructions of the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and these steps can be executed in other orders. Moreover, at least a portion of the steps in the flowcharts involved in the various embodiments described above can include multiple steps or multiple stages, and these steps or stages are not necessarily executed and completed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a portion of steps or stages in other steps.
[0111] Based on the same inventive concept, embodiments of the present application also provide a query device for implementing the query method described above. The solution provided by this device is similar to the solution described in the method described above. Therefore, the specific limitations of one or more query device embodiments provided below can be found in the above-mentioned limitations of the query method and will not be repeated here.
[0112] In one embodiment, Figure 5 As shown, a query device is provided, comprising: an information receiving module, a component determining module, a result obtaining module and a result sending module, wherein:
[0113] The information receiving module is used to receive a query request sent by the terminal; the query request includes the number of target forms to be queried;
[0114] A result acquisition module is used to obtain the query result corresponding to the query request through a preset accelerated query component if the number of target forms is less than or equal to a preset value; the accelerated query component is a component that obtains the query result from the target in-memory database in the server cluster;
[0115] The result sending module is used to send the query results to the terminal.
[0116] In one embodiment, the query device includes: a second result acquisition module configured to, if the number of target forms is greater than a preset value, acquire a query result corresponding to the query request via an original query component; the original query component is a component that obtains scan results of the target forms in the query request through a cold start scan and processes the scan results to acquire the query result.
[0117] In one embodiment, the result acquisition module includes: if the target query component is an accelerated query component and the target form meets the preset sending conditions, then sending a query request to the target user in the server cluster through the accelerated query component and receiving the query result returned by the target user.
[0118] In one embodiment, the query request includes the location of the target form to be queried, and the preset sending conditions include at least one of the following:
[0119] The location of the target form is in the target in-memory database in the server cluster;
[0120] The target form is not located in the target memory database in the server cluster, the startup status of the target memory database is started, and the data volume of the target form meets the preset first capacity condition.
[0121] In one embodiment, the data volume of the target form satisfies a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database.
[0122] In one embodiment, the device further includes: a memory database startup module, configured to execute a target memory database startup operation if the target form is not located in the target memory database in the server cluster and the startup status of the target memory database is not started; the target memory database startup operation includes: applying for a target container in the resource queue of the target user; and starting the target memory database in the target container.
[0123] In one embodiment, the device also includes: a memory adjustment module, which is used to perform a memory adjustment operation if the location of the target form is not located in the target memory database in the server cluster, and the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition; the memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
[0124] In one embodiment, the second capacity condition includes: the data volume of the target form is within a standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
[0125] Each module in the query device described above may be implemented in whole or in part through software, hardware, or a combination thereof. Each module may be embedded in or independent of a processor in a computer device in the form of hardware, or may be stored in a memory in the computer device in the form of software, so that the processor can call and execute the corresponding operations of each module.
[0126] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store query data. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, a query method is implemented.
[0127] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0128] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0129] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0130] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0131] Send the query results to the terminal.
[0132] In one embodiment, the processor implements the following steps when executing the computer program:
[0133] If the number of target forms is greater than the preset value, the query result corresponding to the query request is obtained through the original query component; the original query component represents a component that obtains the scan result of the target form in the query request through cold start scanning, and obtains the query result after processing the scan result.
[0134] In one embodiment, the processor implements the following steps when executing the computer program:
[0135] If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received.
[0136] In one embodiment, the query request includes the location of the target form to be queried, and the preset sending conditions include at least one of the following: the location of the target form is located in the target memory database in the server cluster; the location of the target form is not located in the target memory database in the server cluster, and the startup status of the target memory database is started, and the data volume of the target form meets the preset first capacity condition.
[0137] In one embodiment, the data volume of the target form meets a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database.
[0138] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0139] If the target form is not located in the target memory database in the server cluster and the startup status of the target memory database is not started, the target memory database startup operation is performed; the target memory database startup operation includes: applying for a target container in the target user's resource queue; and starting the target memory database in the target container.
[0140] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0141] If the location of the target form is not located in the target memory database in the server cluster, and the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then a memory adjustment operation is performed; the memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and then loading the target form into the target memory database.
[0142] In one embodiment, the second capacity condition includes: the data volume of the target form is within a standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
[0143] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0144] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0145] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0146] Send the query results to the terminal.
[0147] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0148] If the number of target forms is greater than the preset value, the query result corresponding to the query request is obtained through the original query component; the original query component represents a component that obtains the scan result of the target form in the query request through cold start scanning, and obtains the query result after processing the scan result.
[0149] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0150] If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received.
[0151] In one embodiment, the query request includes the location of the target form to be queried, and the preset sending conditions include at least one of the following: the location of the target form is located in the target memory database in the server cluster; the location of the target form is not located in the target memory database in the server cluster, and the startup status of the target memory database is started, and the data volume of the target form meets the preset first capacity condition.
[0152] In one embodiment, the data volume of the target form meets a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database.
[0153] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0154] If the target form is not located in the target memory database in the server cluster, and the target memory database is not started, start the target memory database.
[0155] The operation of starting the target in-memory database includes: applying for the target container in the resource queue of the target user;
[0156] Start the target in-memory database in the target container.
[0157] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0158] If the target form is not located in the target memory database in the server cluster, the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then perform a memory adjustment operation;
[0159] The memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
[0160] In one embodiment, the second capacity condition includes: the data volume of the target form is within a standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
[0161] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0162] Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried;
[0163] If the number of target forms is less than or equal to a preset value, the query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component is a component that obtains the query result from the target memory database in the server cluster;
[0164] Send the query results to the terminal.
[0165] In one embodiment, when the computer program is executed by a processor, the following steps are implemented:
[0166] If the number of target forms is greater than the preset value, the query result corresponding to the query request is obtained through the original query component; the original query component represents a component that obtains the scan result of the target form in the query request through cold start scanning, and obtains the query result after processing the scan result.
[0167] In one embodiment, when the computer program is executed by a processor, the following steps are implemented:
[0168] If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received.
[0169] In one embodiment, the query request includes the location of the target form to be queried, and the preset sending conditions include at least one of the following: the location of the target form is located in the target memory database in the server cluster; the location of the target form is not located in the target memory database in the server cluster, and the startup status of the target memory database is started, and the data volume of the target form meets the preset first capacity condition.
[0170] In one embodiment, the data volume of the target form meets a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database.
[0171] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0172] If the target form is not located in the target memory database in the server cluster, and the target memory database is not started, start the target memory database.
[0173] The operation of starting the target in-memory database includes: applying for the target container in the resource queue of the target user;
[0174] Start the target in-memory database in the target container.
[0175] In one embodiment, when the computer program is executed by a processor, the following steps are further implemented:
[0176] If the target form is not located in the target memory database in the server cluster, the startup status of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then perform a memory adjustment operation;
[0177] The memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
[0178] In one embodiment, the second capacity condition includes: the data volume of the target form is within a standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
[0179] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties.
[0180] It should be noted that the query method and query device involved in this application can be used in the financial field for data query, and can also be used in any field other than the financial field. The application field of the query method and query device involved in this application is not limited.
[0181] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory may include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in the various embodiments provided herein may include at least one of a relational database and a non-relational database. Non-relational databases may include, but are not limited to, distributed databases based on blockchains. The processor involved in the various embodiments provided herein may be, but are not limited to, a general-purpose processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, and the like.
[0182] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0183] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present application. It should be noted that a person of ordinary skill in the art may make various modifications and improvements without departing from the spirit of the present application, and these modifications and improvements fall within the scope of protection of the present application. Therefore, the scope of protection of the present application shall be determined by the appended claims.
Claims
1. A query method, characterized in that: The method comprises: Receiving a query request sent by a terminal; the query request includes the number of target forms to be queried; If the number of target forms is less than or equal to a preset value, a query result corresponding to the query request is obtained through a preset accelerated query component; the accelerated query component represents a component that obtains query results from a target in-memory database in a server cluster, wherein the preset value is set according to the target in-memory database's ability to process the target forms. The accelerated query component is a query connection written when the number of target forms meets the target in-memory database's processing capacity, for data extraction and transmission; the accelerated query component is directly connected to the target in-memory database; Sending the query result to the terminal; The obtaining of the query result corresponding to the query request by using a preset accelerated query component includes: If the target form meets the preset sending conditions, the query request is sent to the target user in the server cluster through the accelerated query component, and the query result returned by the target user is received; wherein the method further includes: If the location of the target form is not located in the target memory database in the server cluster, and the startup state of the target memory database is not started, then executing the operation of starting the target memory database; The starting target memory database operation includes: applying for a target container in the resource queue of the target user; Starting the target in-memory database in the target container; The method further includes: if the number of target forms is greater than the preset value, obtaining a query result corresponding to the query request through an original query component; the original query component represents a component that obtains a scan result of the target form in the query request through a cold start scan and processes the scan result to obtain a query result; The query request includes the location of the target form to be queried, and the predetermined sending condition includes at least one of the following: The target form is located in a target memory database in the server cluster; The target form is not located in the target memory database in the server cluster, the startup state of the target memory database is started, and the data volume of the target form meets a preset first capacity condition; The data volume of the target form satisfies a preset first capacity condition, including: The data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target in-memory database; The location of the target form is the location address of the target form in the data storage system.
2. The method according to claim 1, characterized in that The method further comprises: If the target form is not located in the target memory database in the server cluster, the startup state of the memory database is started, and the data volume of the target form meets the preset second capacity condition, then performing a memory adjustment operation; The memory adjustment operation includes: deleting the loaded forms in the memory database in sequence according to the least access principle until the remaining memory capacity of the memory database is greater than or equal to the data volume of the target form, and loading the target form into the target memory database.
3. The method according to claim 2, characterized in that The second capacity condition includes: The data volume of the target form is within the standard threshold range, and the data volume of the target form is greater than the remaining memory capacity of the memory database.
4. A query device, characterized in that: The device comprises: An information receiving module, configured to receive a query request sent by a terminal; the query request includes the number of target forms to be queried; A result acquisition module, configured to obtain the query result corresponding to the query request via a preset accelerated query component if the number of target forms is less than or equal to a preset value; the accelerated query component represents a component that obtains the query result from a target in-memory database in the server cluster, wherein the preset value is set based on the target in-memory database's ability to process the target forms. The accelerated query component creates a query connection for data extraction and transmission when the number of target forms meets the target in-memory database's processing capacity; the accelerated query component is directly connected to the target in-memory database; A result sending module, configured to send the query result to the terminal; Wherein, the device is further configured to send the query request to the target user in the server cluster through the accelerated query component if the target form meets the preset sending conditions, and receive the query result returned by the target user; The device is further configured to, if the target form is not located in the target memory database in the server cluster and the target memory database is in a startup state of not started, execute an operation of starting the target memory database; the operation of starting the target memory database includes: applying for a target container in the resource queue of the target user; starting the target memory database in the target container; The device is further configured to obtain, if the number of target forms is greater than the preset value, a query result corresponding to the query request through an original query component; the original query component represents a component that obtains a scan result of the target form in the query request through a cold start scan and processes the scan result to obtain a query result; The query request includes the location of the target form to be queried, and the satisfying of the preset sending condition includes at least one of the following: the location of the target form is located in the target memory database in the server cluster; the location of the target form is not located in the target memory database in the server cluster, the startup state of the target memory database is started, and the data volume of the target form meets the preset first capacity condition; The data volume of the target form satisfies a preset first capacity condition, including: the data volume of the target form is within a standard threshold range, and the data volume of the target form is less than or equal to the memory capacity of the target memory database; The location of the target form is the location address of the target form in the data storage system.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
7. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Method and device for querying data, computer equipment and storage medium
CN108664613A
Big-data-based query method and device, computer device and storage medium
CN109033123A
Method and device for processing memory data
CN109189845A
Data query platform, method, and equipment and storage medium
CN110222072A
Alarm information management method, alarm information management system and server
CN113055213A