CN116126905A - Database query method and device, electronic equipment and storage medium - Google Patents

Database query method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN116126905A
CN116126905A CN202211214817.XA CN202211214817A CN116126905A CN 116126905 A CN116126905 A CN 116126905A CN 202211214817 A CN202211214817 A CN 202211214817A CN 116126905 A CN116126905 A CN 116126905A
Authority
CN
China
Prior art keywords
database
query
accelerator
server
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211214817.XA
Other languages
Chinese (zh)
Inventor
文亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Feixun Digital Technology Co ltd
Original Assignee
Beijing Feixun Digital Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Feixun Digital Technology Co ltd filed Critical Beijing Feixun Digital Technology Co ltd
Priority to CN202211214817.XA priority Critical patent/CN116126905A/en
Publication of CN116126905A publication Critical patent/CN116126905A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24564Applying rules; Deductive queries
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/24Querying
    • G06F16/245Query processing
    • G06F16/2455Query execution
    • G06F16/24552Database cache management
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the invention discloses a database query method, a database query device, electronic equipment and a storage medium. The database query method specifically may include: acquiring a database query request sent by a database client through the database accelerator; determining a query rule of the database query request according to the database query request through the database accelerator; responding to the database query request by the database accelerator according to the query rule; wherein the query rules comprise database query types and database caching rules. The technical scheme of the embodiment of the invention can reduce the response time of database query and improve the response rate of database query.

Description

Database query method and device, electronic equipment and storage medium
Technical Field
The embodiment of the invention relates to the technical field of databases, in particular to a database query method, a database query device, electronic equipment and a storage medium.
Background
In existing database client/server configurations, one or more database clients may query a backend database server over a network. The database server executes the query and returns the results to the client requesting them.
For each query of a database client, the database server must process the structured database query, compile it into a form that can be understood by the database storage engine, physically retrieve the chunk data from the disk system in which it resides for consistency and persistence, filter the chunk data, and ensure that only the portion specified in the query is sent back to the database client. But the process is complex and highly repeatable, reducing the response rate to database queries.
Disclosure of Invention
The embodiment of the invention provides a database query method, a device, electronic equipment and a storage medium, which can reduce the response time of database query and improve the response rate of database query.
According to an aspect of the present invention, there is provided a database query method, including:
acquiring a database query request sent by a database client through a database accelerator;
determining a query rule of the database query request according to the database query request through the database accelerator;
responding to the database query request by the database accelerator according to the query rule;
Wherein the query rules comprise database query types and database caching rules.
According to another aspect of the present invention, there is provided a database query apparatus including:
the database query request acquisition module is used for acquiring a database query request sent by a database client through a database accelerator;
the query rule determining module is used for determining a query rule of the database query request according to the database query request through the database accelerator;
the response data query module is used for querying response data of the database query request according to the query rule through the database accelerator; wherein the query rules comprise database query types and database caching rules.
According to another aspect of the present invention, there is provided an electronic apparatus including:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the database query method of any one of the embodiments of the present invention.
According to another aspect of the present invention, there is provided a computer readable storage medium storing computer instructions for causing a processor to execute a database query method according to any embodiment of the present invention.
According to the technical scheme, the database accelerator is used for acquiring the database query request of the sending end of the database client, so that the query rule of the database query request is determined according to the database query request, and the database accelerator is used for responding to the query of the data of the database query request according to the database query type and the database cache rule in the query rule. According to the technical scheme, the database query request is responded through the database accelerator, and the query rule is set in the database query request, so that the query can be performed according to the database query type and the database cache rule in the query rule when the response data is queried through the database accelerator, the expenditure involved in executing the query on the database server is reduced, the response time of the database query is shortened, and the response speed of the database query is improved.
It should be understood that the description in this section is not intended to identify key or critical features of the embodiments of the invention or to delineate the scope of the invention. Other features of the present invention will become apparent from the description that follows.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for the description of the embodiments will be briefly described below, and it is apparent that the drawings in the following description are only some embodiments of the present invention, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flowchart of a database query method according to a first embodiment of the present invention;
FIG. 2 is a flowchart of a database query method according to a second embodiment of the present invention;
FIG. 3 is a schematic diagram of a database network architecture according to a third embodiment of the present invention;
fig. 4 is an exemplary schematic diagram of a database query method according to a third embodiment of the present invention;
FIG. 5 is another schematic diagram of a database query method according to a third embodiment of the present invention;
fig. 6 is a schematic diagram of a database query device according to a fourth embodiment of the present invention;
Fig. 7 is a schematic structural diagram of an electronic device implementing a database query method according to an embodiment of the present invention.
Detailed Description
In order that those skilled in the art will better understand the present invention, a technical solution in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in which it is apparent that the described embodiments are only some embodiments of the present invention, not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the present invention without making any inventive effort, shall fall within the scope of the present invention.
It is noted that the terms "comprises" and "comprising," and any variations thereof, in the description and claims of the present invention and in the foregoing figures, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus.
Example 1
Fig. 1 is a flowchart of a database query method provided in an embodiment of the present invention, where the embodiment is applicable to a case of reducing response time of a database query and improving response rate of the database query, the method may be performed by a database query device, and the device may be implemented by software and/or hardware, and may generally be directly integrated in an electronic device executing the method, where the electronic device may be a terminal device or a server device, and the embodiment of the present invention does not limit types of electronic devices executing the database query method. Specifically, as shown in fig. 1, the database query method specifically includes the following steps:
s110, acquiring a database query request sent by a database client through a database accelerator.
The database client may be any client that initiates a database query to a database server. The database client may be a Web (World Wide Web) server, an application server, or a mixture of Web servers and application servers, which is not limited in this embodiment of the present invention. The database query request may be any request sent by a database client to a database server to query the database. The database accelerator may be a database middleware disposed between the database client and the database server for responding to database query requests.
In the embodiment of the invention, a database query request sent by a database client is acquired through a database accelerator. It will be appreciated that the database query request sent by the database client may be obtained through a network port of the database accelerator.
S120, determining a query rule of the database query request according to the database query request through the database accelerator.
The query rules may be rules that are followed when making database queries, among other things. It is understood that when the database client sends a database query request, the database query request may be sent according to a query rule.
In the embodiment of the invention, after the database query request sent by the database client is acquired through the database accelerator, the query rule of the database query request can be further determined through the database accelerator according to the database query request.
Alternatively, the query rules may include database query types and database caching rules.
The database query type may be a query type when the database query is performed, for example, a query type for reading data in the database, a query type for writing data into the database, etc., which is not limited in the embodiment of the present invention. The database caching rules may be rules that cache data in a database. It can be understood that when the database query is performed, the response data of the query can meet the database caching rule so as to query the response data in the cache, thereby reducing the response time of the database query and improving the response rate of the database query.
Specifically, after the database query request sent by the database client is obtained through the database accelerator, the database query type and the database cache rule of the database query request can be further determined through the database accelerator according to the database query request.
S130, inquiring response data of the database inquiry request through the database accelerator according to the inquiry rule.
The response data may be data to be queried in the database query request.
In the embodiment of the invention, after the database accelerator determines the query rule of the database query request according to the database query request, the database accelerator can further respond to the query of the data to the database query request according to the database query type and the database cache rule in the query rule. It will be appreciated that after the response data is queried, the response data may be sent to the database client through the network port of the database accelerator.
According to the technical scheme, the database accelerator is used for acquiring the database query request of the sending end of the database client, so that the query rule of the database query request is determined according to the database query request, and the database accelerator is used for responding to the query of the data of the database query request according to the database query type and the database cache rule in the query rule. According to the technical scheme, the database query request is responded through the database accelerator, and the query rule is set in the database query request, so that the query can be performed according to the database query type and the database cache rule in the query rule when the response data is queried through the database accelerator, the expenditure involved in executing the query on the database server is reduced, the response time of the database query is shortened, and the response speed of the database query is improved.
Example two
Fig. 2 is a flowchart of a database query method provided by a second embodiment of the present invention, where the present embodiment further refines the above technical solutions, and provides various specific alternative implementations for responding to a query of data to a database query request by a database accelerator according to the query rule. The technical solution in this embodiment may be combined with each of the alternatives in one or more embodiments described above. As shown in fig. 2, the method may include the steps of:
s210, acquiring a database query request sent by a database client through a database accelerator.
Alternatively, the database query request may be a request sent to a particular database server. Wherein the specific database server may be a database server of a specific IP (internet protocol) address and port. Specifically, a database query request sent by a database client to a database server with a specific IP address and port may be obtained through a network port of a database accelerator.
Optionally, before the database accelerator obtains the database query request sent by the database client, the method may further include: determining a preset cache rule through a database accelerator; the preset caching rules comprise server identifications, database query modes and data identifications; determining a cache database server according to the server identification through a database accelerator; acquiring target data in a cache database server through a database accelerator according to a database query mode and a data identifier, and storing the target data into a preset cache through the database accelerator; and determining the survival time of the preset caching rules through the database accelerator, and deleting the target data from the preset cache under the condition that the database accelerator determines that the storage time of the target data in the preset cache reaches the survival time.
The preset caching rule may be a preset rule for caching data in a database. The server identification may be used to uniquely identify the database server, such as an IP address and port of the database server, as the embodiments of the invention are not limited in this respect. The database query mode may be a specific query mode when performing database query, for example, may be a single database query performed by using SQL statements, or may be a joint database query performed by using SQL statements, which is not limited in the embodiment of the present invention. The data identification may be an identification of the location where the data is located. The data identifier may be an identifier of a database where data is located, an identifier of a table where data is located, or an identifier of a column where data is located, which is not limited in this embodiment of the present invention.
Wherein, when caching data in a database server, the database server can be determined to be a cached database server. The target data may be data that needs to be cached in a cache database server. The preset cache may be a preset cache, and may be used to store target data in the cache database server. It may be appreciated that the preset cache may be a memory in the database server, or an external memory, which is not limited in this embodiment of the present invention.
Specifically, before a database query request sent by a database client is acquired through a database accelerator, a server identifier, a database query mode and a data identifier in a preset cache rule can be determined through the database accelerator, so that a cache database server is determined through the database accelerator according to the server identifier, and target data in the cache database server is acquired through the database accelerator according to the database query mode and the data identifier, so that the target data is stored into the preset cache through the database accelerator.
Specifically, after the target data is stored in the preset cache by the database accelerator, the survival time of the preset cache rule may be further determined by the database accelerator, and when the storage time of the target data in the preset cache is determined to reach the survival time by the database accelerator, the target data is deleted from the preset cache.
Optionally, the cache data in the preset cache may be deleted according to the actual requirement. Specifically, the cached data in the preset cache may be deleted at any granularity level (e.g., key, table, schema, or database) or database client cluster.
Alternatively, the cached data in the preset cache may be stored in the key value pair. Wherein the key may uniquely identify the query and the value may be a pointer to return data in the default cache. In order to ensure that when multiple database clients send database query requests, different databases and table sets can be provided without data cache overlap, keys may be mapped to queries, or may be mapped to a broad metadata set containing database names, such as table names, credentials of the database clients requesting queries, or storage time of cache data, or may also be hashes of these components, etc., the embodiments of the present invention are not limited in this respect.
Optionally, after storing the target data in the preset buffer by the database accelerator, the method may further include: when the preset timing task is triggered, the cache data in the preset cache are stored into the persistent storage device through the database accelerator.
The preset timing task may be a task that performs storing cache data in a preset cache to the persistent storage device at a preset timing. The cache data may be data in a preset cache. The persistent storage device may be a device capable of persistently storing data. By way of example, the persistent storage device may be a hard drive, a solid state drive (e.g., SSD), or the like, as the embodiments of the invention are not limited in this regard.
Specifically, after the target data is stored into the preset cache through the database accelerator, when the preset timing task is triggered, the cache data in the preset cache can be further stored into the persistent storage device through the database accelerator.
It can be appreciated that the preset cache may use a volatile memory (such as RAM), and when there is response data in the cache, the response data may be immediately returned to the database client, without performing disk access (i.e. without connecting to the database server), so as to quickly respond to the database query request. However, in the case of a cache crash or a system restart, the cache data in the default cache will be purged, resulting in a cold start problem. However, no cache data is preset in the cache after the cache data is cleared, and a database server needs to be connected when a database query is requested, which may incur considerable calculation time cost. Therefore, the cache data in the preset cache can be stored in the persistent storage device periodically. The persistent storage device does not affect the delayed write mechanism of memory performance.
According to the technical scheme, the cache data in the preset cache is stored in the persistent storage device at regular intervals, so that the data in the persistent storage device can be read when the system is restarted, and the data in the persistent storage device can be rewritten into the preset cache. When a database query request is received, cache data are stored in a preset cache, so that the problem of cold start can be solved, and repeated crashes of a database server are avoided. It should be noted that the persistent storage device is only used to restore the cached data in the preset cache after the system is restarted, and is not used to respond to the database query request, so as to avoid affecting the response time of the database query.
S220, determining a query rule of the database query request according to the database query request through the database accelerator.
S230, determining whether the database caching rule meets a preset caching rule or not under the condition that the database query type is determined to be database read query by the database accelerator; if yes, executing S240; otherwise, S250 is performed.
The database read query may be a query to read data in a database.
In the embodiment of the invention, after the database accelerator determines the query rule of the database query request according to the database query request, the database accelerator can further determine whether the database cache rule meets the preset cache rule under the condition that the database query type is determined to be the database read query.
Specifically, if the database caching rule meets the preset caching rule, the response data matched with the database query request can be queried in the preset cache through the database accelerator. If the database caching rules do not meet the preset caching rules, the database query request can be sent to the target database server through the database accelerator so as to query response data matched with the database query request through the target database server.
S240, inquiring response data matched with the database inquiry request in a preset cache through the database accelerator, wherein the preset cache comprises cache data prestored according to the preset cache rule.
In the embodiment of the invention, after determining that the database caching rule meets the preset caching rule under the condition that the database query type is determined to be the database read query by the database accelerator, the response data matched with the database query request can be further queried in the preset cache by the database accelerator. It may be appreciated that the preset cache may include cache data stored in advance according to a preset cache rule.
Optionally, after the database accelerator queries the response data matched with the database query request in the preset cache, the method further includes: if no response data is queried in the preset cache, a database query request is sent to a target database server through a database accelerator so as to query the response data matched with the database query request through the target database server.
Wherein the target database server may be a database server that matches the database query request. It will be appreciated that when a database query is performed on a database query request, the queried database server is the target database server. Alternatively, the database query request sent by the database client may be a database query request initiated to a database server with a specific IP address and port, which is the target database server.
Specifically, if no response data is queried in the preset cache, the database query request may be sent to the target database server through the database accelerator, so as to query, through the target database server, the response data matching the database query request.
Optionally, sending, by the database accelerator, the database query request to the target database server may include: determining a target database server matched with the database query request through a database accelerator, and sending a connection establishment request to the target database server; and acquiring a target new connection fed back by the target database server according to the connection establishment request through the database accelerator, and sending a database query request to the target database server through the database accelerator according to the target new connection.
Wherein the connection establishment request may be a request to establish a connection with the target database server. The target newly-established connection may be a connection with the target database server.
Specifically, if no response data is queried in the preset cache, determining a target database server matched with the database query request through the database accelerator, sending a connection establishment request to the target database server, acquiring a target new connection fed back by the target database server according to the connection establishment request through the database accelerator, and sending the database query request to the target database server through the database accelerator according to the target new connection, so that the response data matched with the database query request is queried through the target database server.
Optionally, after querying, by the target database server, the response data matching the database query request, it may further include: and acquiring response data fed back by the target database server through the database accelerator, and storing the response data in a preset cache.
Specifically, if no response data is queried in the preset buffer, after the database query request is sent to the target database server through the database accelerator to query the response data matched with the database query request through the target database server, the response data fed back by the target database server may be further acquired through the database accelerator, and the response data may be stored in the preset buffer. Alternatively, response data may be associated with the query key, time-to-live, and metadata set for use in responding to the same database query request in a preset cache.
S250, sending the database query request to a target database server through the database accelerator so as to query response data matched with the database query request through the target database server.
In the embodiment of the invention, when the database accelerator determines that the database query type is the database read query, after determining that the database caching rule does not meet the preset caching rule, the database accelerator may further send the database query request to the target database server to query the response data matched with the database query request through the target database server.
Optionally, after determining, by the database accelerator, that the database cache rule does not meet the preset cache rule under the condition that the database query type is determined to be the database read query, the target database server matched with the database query request may be further determined by the database accelerator, and the connection establishment request is sent to the target database server, so as to obtain, by the database accelerator, a new connection of the target database server according to the target fed back by the connection establishment request, and send, by the database accelerator, the database query request to the target database server according to the new connection of the target, thereby querying, by the target database server, response data matched with the database query request.
And S260, under the condition that the database query type is determined to be database write query through the database accelerator, sending the database query request to a target database server through the database accelerator so as to query response data matched with the database query request through the target database server.
Wherein the database write query may be a query to write data in the database.
In the embodiment of the invention, after the query rule of the database query request is determined according to the database query request through the database accelerator, the database query request can be further sent to the target database server through the database accelerator under the condition that the database query type is database write query, so as to query the response data matched with the database query request through the target database server.
Optionally, in the case that the database query type is a database write query, the target database server matched with the database query request can be determined through the database accelerator, and a connection establishment request is sent to the target database server, so that a new target connection fed back by the target database server according to the connection establishment request is obtained through the database accelerator, and the database query request is sent to the target database server through the database accelerator according to the new target connection, so that response data matched with the database query request is queried through the target database server.
Optionally, the method may include: under the condition that the database query request is determined to be the client user authentication request by the database accelerator, the user authentication information matched with the client user authentication request is queried in a preset cache by the database accelerator.
The client user authentication request may be a request for user authentication sent by the client. The user authentication information may be information for user authentication cached in advance in a preset cache. By way of example, the user authentication information may be a user name, password, etc., and embodiments of the present invention are not limited in this regard.
Specifically, when the database accelerator determines that the database query request is a client user authentication request, the database accelerator may query the preset cache for user authentication information matched with the client user authentication request to authenticate the client user authentication request.
According to the technical scheme of the embodiment, a database query request sent by a database client is obtained through a database accelerator, and a query rule of the database query request is determined through the database accelerator according to the database query request, so that whether the database query type is database read query or database write query is determined through the database accelerator. When the database query type is determined to be the database read query, whether the database caching rule meets the preset caching rule is further determined through the database accelerator. And if the database caching rule meets the preset caching rule, inquiring response data matched with the database inquiry request in the preset cache through the database accelerator. If the database caching rules do not meet the preset caching rules, the database query request is sent to the target database server through the database accelerator, so that response data matched with the database query request is queried through the target database server. When the database query type is database write query, the database query request is sent to the target database server through the database accelerator so as to query response data matched with the database query request through the target database server. According to the technical scheme, when the database caching rule meets the preset caching rule, the response data is queried in the preset cache through the database accelerator, so that the database query request can be immediately responded without being processed by the database server, the response time of the database query is shortened, and the response rate of the database query is improved.
Example III
In order to enable those skilled in the art to better understand the database query method according to the embodiments of the present invention, a specific example will be described below.
In the prior art, a database client transmits a database query to a public IP address and port number combination on a database server, which then transmits response data back to the IP address of the database client initiating the query. Prior to database querying, an authentication process is followed by the database client providing authentication credentials (e.g., a user name and password) to the database server, and the database server establishing a connection, which may be identified by a connection ID, from which the database client may perform the database query. The database servers in the above solutions are typically single computer systems, however in some implementations the database servers may be clusters of computer systems. Even though the database server is a cluster of computer systems, it appears to the database client as a single server reached through a single IP address and port number combination.
Many more complex database clients and database server configurations support the concept of master-slave replication to distribute or spread the load of read queries and write queries among multiple servers. The database servers configured as master-slave replication form a cluster and run in synchronization with each other to ensure that data between all database servers in the cluster is up-to-date. Master-slave replication can allow database client administrators to extend read performance, with the master database server handling all write, operational data (e.g., insert data or update data) queries, and the remaining read queries can be distributed between the master database server and the slave database servers.
In a typical master-slave database architecture, there are designated master-slave database servers. The master database server is capable of processing read queries and write queries, while the slave database servers process read queries. The most common replication method in a typical master-slave cluster is to read the transaction log on the master database server from the database server, which stores the SQL statements of all the operational databases and executes them locally to ensure that the master-slave database servers are synchronized. Some replication architectures may also use a separate replication manager component to monitor changes to the master database server, and once a change is found, push the change to the slave database server, freeing both the master and slave database servers from the complexity of maintaining synchronization.
The interface between a database server and a database client is commonly referred to as database middleware. One limitation often encountered in conventional database systems is the overhead involved in performing simple read-only queries. To overcome this overhead, some more complex database systems implement a query caching system in the database client or database server, or both. But to implement the query caching in a more basic database system requires modification in the database client or database server, or software addition to the database client or database server, or both, to be able to identify that data is requested.
For example, conventional database systems implementing query caching lack configuration management tools or layers that enable application developers or database administrators to specify rules or metadata for queries to be cached without modifying the underlying database client code or database server configuration. Conventional database systems also do not include mechanisms to purge or delete particular cache entries or groups of cache entries from the query cache system as needed.
Fig. 3 is a schematic structural diagram of a database network system according to a third embodiment of the present invention, and as shown in fig. 3, the database system architecture includes a database client, a database accelerator (i.e. a query cache system), and a database server. In particular, the database system is an application that is executing a simple database driver and is not a cluster, i.e., the application directs all queries (whether read or write) to a single IP address and port combination of a single database server. However, for client applications, the single IP address and port combination is the database accelerator IP address and port combination, rather than the database server IP address and port combination. Thus, all database queries from clients are received at the database accelerator by the network port on the database accelerator.
Fig. 4 is an exemplary schematic diagram of a database query method according to a third embodiment of the present invention, as shown in fig. 4, where the method specifically may include: the query cache system may receive a database connection request sent by the database client, and receive a database query request sent by the database client after the query cache system connects the database client. It is determined whether the database query request is a database read query or a database write query. When the database query request is a database read query, it is determined whether the query data (i.e., the response data) is in the buffer (i.e., the preset buffer). If the query data is in the buffer, the query result, i.e., the response data, is read from the buffer and the database query is ended. If the query data is not in the buffer, the query cache system selects a connection from the database server for the database read query. When the database query request is a database write query, the query cache system selects a connection from the database server for the database write query.
Optionally, the query caching system may further comprise a configuration management interface. The database manager may configure the query cache system through the configuration management interface, or may monitor the cache system and operate on it at any level of granularity without modifying or expanding the application code or database server in any way.
The above technical solution, the query caching function of the query caching system may be embodied in a facility between a cluster of conventional database servers and the application programs that want to access them. The query caching system may be considered as a database middleware. In one example, the query caching system may take the form of a query caching device with a database client disposed on one side and a database server cluster disposed on the other side. Database query requests sent by database clients may be coupled to a database server through a query caching system. The functionality of the query cache system is introduced into the application architecture without requiring additional software or application code modification other than the basic network level configuration. The database client does not need to be aware of the existence of the query cache system.
Fig. 5 is another schematic diagram of another example of a database query method provided in the third embodiment of the present invention, as shown in fig. 5, in an application scenario in which a database query request is for client user authentication, authentication information of each client user may be stored in a preset cache of a query cache system, so that the database server may be replaced, and simulated authentication may be implemented. The authentication protocol is a specification of the process by which a server can determine the authenticity of a client that wants to access the server. Typically, the server implements part of the protocol, while the client implements other parts of the protocol. For many authentication protocols, multiple "authentication transfers" are required between the client and server systems. The protocol typically requires a procedure of at least two authentication transfers, such as a first authentication transfer from the server to the client, a second authentication transfer from the client to the server, and a third authentication transfer from the server back to the client.
According to the technical scheme, the client user authentication can be realized through the query cache system under the condition that the database server is powered off by starting the offline authentication of the query cache system.
Example IV
Fig. 6 is a schematic diagram of a database query device according to a fourth embodiment of the present invention, as shown in fig. 6, where the device includes: a database query request acquisition module 610, a query rule determination module 620, and a response data query module 630, wherein:
a database query request acquisition module 610, configured to acquire, through a database accelerator, a database query request sent by a database client;
a query rule determining module 620, configured to determine, by the database accelerator, a query rule of the database query request according to the database query request;
a response data query module 630, configured to query, by using the database accelerator, response data for the database query request according to the query rule; wherein the query rules comprise database query types and database caching rules.
According to the technical scheme, the database accelerator is used for acquiring the database query request of the sending end of the database client, so that the query rule of the database query request is determined according to the database query request, and the database accelerator is used for responding to the query of the data of the database query request according to the database query type and the database cache rule in the query rule. According to the technical scheme, the database query request is responded through the database accelerator, and the query rule is set in the database query request, so that the query can be performed according to the database query type and the database cache rule in the query rule when the response data is queried through the database accelerator, the expenditure involved in executing the query on the database server is reduced, the response time of the database query is shortened, and the response speed of the database query is improved.
Optionally, the response data query module 630 may be specifically configured to: determining whether a database caching rule meets a preset caching rule by a database accelerator under the condition that the database query type is determined to be database read query; if yes, inquiring response data matched with the database inquiry request in a preset cache through a database accelerator, wherein the preset cache comprises cache data prestored according to a preset cache rule; if not, the database query request is sent to the target database server through the database accelerator so as to query response data matched with the database query request through the target database server.
Optionally, the response data query module 630 may be further specifically configured to: if no response data is queried in the preset cache, a database query request is sent to a target database server through a database accelerator so as to query the response data matched with the database query request through the target database server.
Optionally, the response data query module 630 may be further specifically configured to: and acquiring response data fed back by the target database server through the database accelerator, and storing the response data in a preset cache.
Optionally, the database query request acquisition module 610 may be specifically configured to: determining a preset cache rule through a database accelerator; the preset caching rules comprise server identifications, database query modes and data identifications; determining a cache database server according to the server identification through a database accelerator; acquiring target data in a cache database server through a database accelerator according to a database query mode and a data identifier, and storing the target data into a preset cache through the database accelerator; and determining the survival time of the preset caching rules through the database accelerator, and deleting the target data from the preset cache under the condition that the database accelerator determines that the storage time of the target data in the preset cache reaches the survival time.
Optionally, the database query request acquisition module 610 may be specifically configured to: when the preset timing task is triggered, the cache data in the preset cache are stored into the persistent storage device through the database accelerator.
Optionally, the response data query module 630 may be further specifically configured to: and under the condition that the database query type is determined to be the database write query by the database accelerator, sending a database query request to a target database server by the database accelerator so as to query response data matched with the database query request by the target database server.
Optionally, the response data query module 630 may be further specifically configured to: determining a target database server matched with the database query request through a database accelerator, and sending a connection establishment request to the target database server; acquiring a target newly-built connection fed back by a target database server according to the connection establishment request through a database accelerator; and sending the database query request to the target database server through the database accelerator according to the target newly-built connection.
Optionally, the database query device may be further specifically configured to: under the condition that the database query request is determined to be the client user authentication request by the database accelerator, the user authentication information matched with the client user authentication request is queried in a preset cache by the database accelerator.
The database query device provided by the embodiment of the invention can execute the database query method provided by any embodiment of the invention, and has the corresponding functional modules and beneficial effects of the execution method.
Example five
Fig. 7 shows a schematic diagram of the structure of an electronic device 10 that may be used to implement an embodiment of the invention. Electronic devices are intended to represent various forms of digital computers, such as laptops, desktops, workstations, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. Electronic equipment may also represent various forms of mobile devices, such as personal digital processing, cellular telephones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions, are meant to be exemplary only, and are not meant to limit implementations of the inventions described and/or claimed herein.
As shown in fig. 7, the electronic device 10 includes at least one processor 11, and a memory, such as a Read Only Memory (ROM) 12, a Random Access Memory (RAM) 13, etc., communicatively connected to the at least one processor 11, in which the memory stores a computer program executable by the at least one processor, and the processor 11 may perform various appropriate actions and processes according to the computer program stored in the Read Only Memory (ROM) 12 or the computer program loaded from the storage unit 18 into the Random Access Memory (RAM) 13. In the RAM 13, various programs and data required for the operation of the electronic device 10 may also be stored. The processor 11, the ROM 12 and the RAM 13 are connected to each other via a bus 14. An input/output (I/O) interface 15 is also connected to bus 14.
Various components in the electronic device 10 are connected to the I/O interface 15, including: an input unit 16 such as a keyboard, a mouse, etc.; an output unit 17 such as various types of displays, speakers, and the like; a storage unit 18 such as a magnetic disk, an optical disk, or the like; and a communication unit 19 such as a network card, modem, wireless communication transceiver, etc. The communication unit 19 allows the electronic device 10 to exchange information/data with other devices via a computer network, such as the internet, and/or various telecommunication networks.
The processor 11 may be a variety of general and/or special purpose processing components having processing and computing capabilities. Some examples of processor 11 include, but are not limited to, a Central Processing Unit (CPU), a Graphics Processing Unit (GPU), various specialized Artificial Intelligence (AI) computing chips, various processors running machine learning model algorithms, digital Signal Processors (DSPs), and any suitable processor, controller, microcontroller, etc. The processor 11 performs the various methods and processes described above, such as database query methods.
In some embodiments, the database query method may be implemented as a computer program tangibly embodied on a computer-readable storage medium, such as storage unit 18. In some embodiments, part or all of the computer program may be loaded and/or installed onto the electronic device 10 via the ROM 12 and/or the communication unit 19. When the computer program is loaded into RAM 13 and executed by processor 11, one or more of the steps of the database query method described above may be performed. Alternatively, in other embodiments, the processor 11 may be configured to perform the database query method in any other suitable manner (e.g., by means of firmware).
Various implementations of the systems and techniques described here above may be implemented in digital electronic circuitry, integrated circuit systems, field Programmable Gate Arrays (FPGAs), application Specific Integrated Circuits (ASICs), application Specific Standard Products (ASSPs), systems On Chip (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and/or combinations thereof. These various embodiments may include: implemented in one or more computer programs, the one or more computer programs may be executed and/or interpreted on a programmable system including at least one programmable processor, which may be a special purpose or general-purpose programmable processor, that may receive data and instructions from, and transmit data and instructions to, a storage system, at least one input device, and at least one output device.
A computer program for carrying out methods of the present invention may be written in any combination of one or more programming languages. These computer programs may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus, such that the computer programs, when executed by the processor, cause the functions/acts specified in the flowchart and/or block diagram block or blocks to be implemented. The computer program may execute entirely on the machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
In the context of the present invention, a computer-readable storage medium may be a tangible medium that can contain, or store a computer program for use by or in connection with an instruction execution system, apparatus, or device. The computer readable storage medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. Alternatively, the computer readable storage medium may be a machine readable signal medium. More specific examples of a machine-readable storage medium would include an electrical connection based on one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
To provide for interaction with a user, the systems and techniques described here can be implemented on an electronic device having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to a user; and a keyboard and a pointing device (e.g., a mouse or a trackball) through which a user can provide input to the electronic device. Other kinds of devices may also be used to provide for interaction with a user; for example, feedback provided to the user may be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user may be received in any form, including acoustic input, speech input, or tactile input.
The systems and techniques described here can be implemented in a computing system that includes a background component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such background, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: local Area Networks (LANs), wide Area Networks (WANs), blockchain networks, and the internet.
The computing system may include clients and servers. The client and server are typically remote from each other and typically interact through a communication network. The relationship of client and server arises by virtue of computer programs running on the respective computers and having a client-server relationship to each other. The server can be a cloud server, also called a cloud computing server or a cloud host, and is a host product in a cloud computing service system, so that the defects of high management difficulty and weak service expansibility in the traditional physical hosts and VPS service are overcome.
It should be appreciated that various forms of the flows shown above may be used to reorder, add, or delete steps. For example, the steps described in the present invention may be performed in parallel, sequentially, or in a different order, so long as the desired results of the technical solution of the present invention are achieved, and the present invention is not limited herein.
The above embodiments do not limit the scope of the present invention. It will be apparent to those skilled in the art that various modifications, combinations, sub-combinations and alternatives are possible, depending on design requirements and other factors. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of the present invention.

Claims (12)

1. A database query method, comprising:
acquiring a database query request sent by a database client through a database accelerator;
determining a query rule of the database query request according to the database query request through the database accelerator;
responding to the database query request by the database accelerator according to the query rule;
Wherein the query rules comprise database query types and database caching rules.
2. The method of claim 1, wherein said querying, by the database accelerator, the database query request for response data according to the query rule, comprises:
determining, by the database accelerator, whether the database caching rule meets a preset caching rule under the condition that the database query type is determined to be a database read query;
if yes, inquiring response data matched with the database inquiry request in a preset cache through the database accelerator; the preset cache comprises cache data which are stored in advance according to the preset cache rule;
if not, the database query request is sent to a target database server through the database accelerator, so that response data matched with the database query request is queried through the target database server.
3. The method of claim 2, further comprising, after the querying, by the database accelerator, in a preset cache, response data matching the database query request:
And if no response data is queried in the preset cache, sending the database query request to a target database server through the database accelerator so as to query the response data matched with the database query request through the target database server.
4. A method according to claim 3, further comprising, after said querying, by said target database server, response data matching said database query request:
and acquiring the response data fed back by the target database server through the database accelerator, and storing the response data in the preset cache.
5. The method of claim 1, further comprising, prior to said obtaining, by said database accelerator, a database query request sent by a database client:
determining a preset cache rule through the database accelerator; the preset caching rules comprise server identifications, database query modes and data identifications;
determining a cache database server according to the server identification through the database accelerator;
acquiring target data in the cache database server according to the database query mode and the data identification through the database accelerator, and storing the target data into a preset cache through the database accelerator;
And determining the survival time of the preset caching rule through the database accelerator, and deleting the target data from the preset cache under the condition that the database accelerator determines that the storage time of the target data in the preset cache reaches the survival time.
6. The method of claim 5, further comprising, after said storing said target data into a preset cache by said database accelerator:
and when a preset timing task is triggered, storing the cache data in the preset cache into a persistent storage device through the database accelerator.
7. The method of claim 1, wherein said querying, by the database accelerator, the database query request for response data according to the query rule, comprises:
and under the condition that the database query type is determined to be database write query by the database accelerator, sending the database query request to a target database server by the database accelerator so as to query response data matched with the database query request by the target database server.
8. The method of any of claims 2, 3, 7, wherein the sending, by the database accelerator, the database query request to a target database server comprises:
determining a target database server matched with the database query request through the database accelerator, and sending a connection establishment request to the target database server;
acquiring a new connection of the target database server according to the feedback of the connection establishment request through the database accelerator;
and sending the database query request to the target database server through the database accelerator according to the target newly-built connection.
9. The method according to claim 1, wherein the method further comprises:
and under the condition that the database query request is determined to be a client user authentication request by the database accelerator, querying user authentication information matched with the client user authentication request in the preset cache by the database accelerator.
10. A database query apparatus, comprising:
the database query request acquisition module is used for acquiring a database query request sent by a database client through a database accelerator;
The query rule determining module is used for determining a query rule of the database query request according to the database query request through the database accelerator;
the response data query module is used for querying response data of the database query request according to the query rule through the database accelerator; wherein the query rules comprise database query types and database caching rules.
11. An electronic device, the electronic device comprising:
at least one processor; and
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores a computer program executable by the at least one processor to enable the at least one processor to perform the database query method of any one of claims 1-9.
12. A computer readable storage medium storing computer instructions for causing a processor to perform the database query method of any one of claims 1-9.
CN202211214817.XA 2022-09-30 2022-09-30 Database query method and device, electronic equipment and storage medium Pending CN116126905A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211214817.XA CN116126905A (en) 2022-09-30 2022-09-30 Database query method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211214817.XA CN116126905A (en) 2022-09-30 2022-09-30 Database query method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN116126905A true CN116126905A (en) 2023-05-16

Family

ID=86308730

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211214817.XA Pending CN116126905A (en) 2022-09-30 2022-09-30 Database query method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN116126905A (en)

Similar Documents

Publication Publication Date Title
CN107943841B (en) Streaming data processing method, system and computer readable storage medium
CN110489417B (en) Data processing method and related equipment
CN109547512B (en) NoSQL-based distributed Session management method and device
US8712961B2 (en) Database caching utilizing asynchronous log-based replication
US11093484B2 (en) Data management method and data management system
US10097659B1 (en) High performance geographically distributed data storage, retrieval and update
WO2023093245A1 (en) Metadata query method based on distributed file system, and device and storage medium
WO2019007010A1 (en) Distributed searching and index updating method and system, servers, and computer devices
EP2947582A1 (en) Computing device and method for executing database operation command
CN110427386B (en) Data processing method, device and computer storage medium
US10474185B2 (en) Timestamp alignment across a plurality of computing devices
WO2020177536A1 (en) Transaction deduplication method, transaction construction method, device and storage medium
WO2014161261A1 (en) Data storage method and apparatus
CN111651424B (en) Data processing method, device, data node and storage medium
CA3131330A1 (en) Database aggregation query method, device and system
WO2023184908A1 (en) Processing method and system for multi-tenant shared data
CN115495473A (en) Database query method and device, electronic equipment and storage medium
CN111046106A (en) Cache data synchronization method, device, equipment and medium
CN113271359A (en) Method and device for refreshing cache data, electronic equipment and storage medium
CN112866339B (en) Data transmission method and device, computer equipment and storage medium
CN116126905A (en) Database query method and device, electronic equipment and storage medium
WO2022135471A1 (en) Multi-version concurrency control and log clearing method, node, device and medium
CN112527900A (en) Method, device, equipment and medium for database multi-copy reading consistency
CN115587119A (en) Database query method and device, electronic equipment and storage medium
CN111259031A (en) Data updating method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination