WO2018035799A1 - Data query method, application and database servers, middleware, and system - Google Patents
Data query method, application and database servers, middleware, and system Download PDFInfo
- Publication number
- WO2018035799A1 WO2018035799A1 PCT/CN2016/096670 CN2016096670W WO2018035799A1 WO 2018035799 A1 WO2018035799 A1 WO 2018035799A1 CN 2016096670 W CN2016096670 W CN 2016096670W WO 2018035799 A1 WO2018035799 A1 WO 2018035799A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- data query
- data
- database
- application server
- result
- 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.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
Definitions
- the present application relates to the field of database technologies, and in particular, to data query methods, applications, and database servers, middleware, and systems.
- a database is organized according to a data model and stores a collection of data in secondary storage.
- This data set has the following characteristics: it does not repeat as much as possible, and optimally serves multiple applications of a specific organization. Its data structure is independent of the application that uses it, and the data is added, deleted, modified, and checked. Unified software for management and control. Therefore, the database provides the underlying data resources for the application that uses it, and the query effect on the data in the database directly affects the performance of the application that uses it.
- the current data query method is: after the application server of the chat application obtains the query request of the user, firstly, the first time is initiated to the database. Query the request to query all contacts who talk to the user; secondly, the second time a query request is initiated to the database to find the last message in conversation with each contact; finally, the last of each contact in chronological order After a message is sorted, the last contact with the user is determined, and a query request is initiated to the database for the third time to query the information of the last contact with the user, and the contact information is fed back to the user.
- the database server needs to be accessed 3 times, and a large amount of data needs to be transmitted to the client for the client to perform the query again after filtering, which is inefficient.
- the embodiment of the present application proposes a data query method, an application, a database server, a middleware, and a system.
- an embodiment of the present application provides a data query method, where the method includes:
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, Or any combination of the above.
- the generating a data query script according to the data query request includes:
- the method further includes:
- the data model is sent to a data storage system such that the data storage system defines a database model based on the data model.
- an embodiment of the application provides an application server, where the application server includes:
- a first obtaining module configured to obtain a data query request
- a generating module configured to generate a data query script according to the data query request acquired by the first obtaining module
- a first sending module configured to send a data query script generated by the generating module to a data storage system
- a receiving module configured to receive a result obtained by the data storage system executing a data query script sent by the first sending module.
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the generating module is configured to acquire a database model and/or an interface configuration parameter from the data storage system, and generate a data query script according to the database model and/or the interface configuration parameter.
- the application server further includes:
- a second acquiring module configured to acquire a data model of data to be stored
- a second sending module configured to send the data model acquired by the second acquiring module to the data storage system, so that the data storage system defines the database model according to the data model.
- an embodiment of the present application provides a data query method, where the method includes:
- the data query result is fed back to the application server.
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the obtaining the data query script from the application server comprises:
- the feeding back the data query result to the application server includes:
- the data query result is fed back to the application server by the middleware.
- the method further includes:
- the establishing an association relationship between the database model and the application server includes:
- an embodiment of the present application provides a database server, where the database server includes:
- An obtaining module configured to obtain a data query script from an application server
- An execution module configured to execute a data query script obtained by the obtaining module, to obtain a data query result
- a feedback module configured to feed back the data query result obtained by the execution module to the application server.
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the obtaining module is configured to obtain a data query script that is distributed by the middleware based on a data query script from an application server;
- the feedback module is configured to feed back the data query result to the application server by using the middleware.
- the database server further includes:
- a receiving module configured to receive a data model sent by the application server
- a definition module configured to define a database model according to a data model received by the receiving module
- the establishing module is configured to issue a database model to the application server, and/or determine an interface configuration parameter of the database model, and issue the interface configuration parameter to the application server.
- an embodiment of the present application provides a data query method, where the method includes:
- an embodiment of the present application provides a middleware, where the middleware includes:
- a first obtaining module configured to acquire a data query script from an application server
- a determining module configured to determine one or more database servers that execute the data query script acquired by the first obtaining module
- a sending module configured to distribute the data query script acquired by the first acquiring module to the database server;
- a second obtaining module configured to obtain a data query result fed back by the database server
- a sending module configured to send the data query result obtained by the second acquiring module to the application server.
- the embodiment of the present application provides a data query system, where the system includes: an application server and a data storage system;
- the application server such as the application server described in the second aspect above;
- the data storage system is composed of the database server according to the above fourth aspect, or the data storage system is composed of the database server according to the above fourth aspect and the middleware as described in the sixth aspect above.
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- FIG. 1 is a schematic diagram of an implementation environment of a data query method according to an embodiment of the present application
- FIG. 2 is a schematic flowchart diagram of a data query method according to another embodiment of the present application.
- FIG. 3 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 4 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 5 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 6 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 7 is a schematic flowchart diagram of an existing data query method according to another embodiment of the present application.
- FIG. 8 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 9 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 10 is a schematic flowchart diagram of another data query method according to another embodiment of the present application.
- FIG. 11 is a schematic structural diagram of an application server according to another embodiment of the present disclosure.
- FIG. 12 is a schematic structural diagram of another application server according to another embodiment of the present disclosure.
- FIG. 13 is a schematic structural diagram of a database server according to another embodiment of the present application.
- FIG. 14 is a schematic structural diagram of another database server according to another embodiment of the present application.
- FIG. 15 is a schematic structural diagram of an intermediate member according to another embodiment of the present application.
- FIG. 16 is a schematic structural diagram of a data query system according to another embodiment of the present application.
- FIG. 1 is a schematic diagram of an implementation environment of a data query method according to an embodiment of the present invention.
- the implementation environment includes a terminal 101, an application server 102, and a data storage system 103.
- the terminal 101 is configured to send a query request to the application server 102, and receive a result obtained by the application server 102 according to the query request.
- the application server 102 After obtaining the query request from the terminal 101, the application server 102 generates a data query script according to the data query request; sends the data query script to the data storage system 103; and receives the result obtained by the data storage system 103 to execute the data query script, and sends the result to the terminal 101. Feedback the result;
- the database model is obtained from the data storage system by the application server.
- the database model may include the data structure of the data storage system, and may also include the data structure and data operation mode of the data storage system.
- a script is an executable file, also called a macro or batch file, written in a specific descriptive language according to a certain format.
- the data query script may include a data query statement and a result analysis statement, wherein the result analysis statement may be a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the data storage system 103 can be implemented in two ways:
- the data storage system 103 is composed of one or more database servers, and the data server includes a memory in which a database is stored. After the database server obtains the data query script from the application server 102, the data query script is executed, the data query result is obtained, and the data query result is fed back to the application server 102.
- the data storage system 103 is composed of a middleware and one or more database servers, wherein the data server includes a memory, and the database stores the database.
- middleware can manage database server resources and network communication, it can connect to multiple database servers. Even if multiple database servers have different interfaces, they can still exchange information with each other through middleware. Therefore, after obtaining the data query script from the application server, the middleware determines one or more database servers that execute the data query script; distributes the data query script to the database server; obtains the data query result fed back by the database server, and queries the data The result is sent to the application server.
- the database server executes the data query script, obtains the data query result, and feeds back the data query result to the middleware.
- the database server may store only data, and may also store data at the same time and cache part of the data. This application does not limit the specific implementation of the database.
- this embodiment provides a data query method.
- the process of the method provided in this embodiment is as follows:
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- generating a data query script according to the data query request including:
- the method further includes:
- the data model is sent to a data storage system to enable the data storage system to define a database model based on the data model.
- this embodiment provides another data query method, and the process of the method is specifically as follows:
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- obtaining a data query script from the application server including:
- Feedback of the data query results to the application server includes:
- the data query results are fed back to the application server through the middleware.
- the method further includes:
- establishing an association between the database model and the application server including:
- this embodiment provides another data query method, and the process flow is as follows:
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- the present application provides a data query method.
- the method provided by the present application can be applied to various services, especially application scenarios with complex query requirements in data-intensive applications, which can break the database access bottleneck and solve the computationally intensive real-time database access problem.
- the terminal queries the contact information of the last conversation through a structured query language, and the data storage system is a database server.
- structured query language is a special purpose programming language, which is a database query and programming language for accessing data and querying, updating and managing relational database systems.
- the database server After receiving the data query script, the database server loads the script through a separately isolated thread of the backend, and after the data query script is given the database permission, the data query script is executed in a certain order.
- the data query script can access the database on the database server, process the data, and when the data processing is completed, the notification returns the processing result.
- the database server receives the data query script in the form of javascript, dynamically loads the script, and queries the database according to the description of the data query script.
- the Node server is an open source cross-platform running environment written in javascript, using Google's V8 engine to execute code. Since javascript itself is a scripting language, it can dynamically load script fragments for execution and execute scripts at runtime. to modify.
- the mongoDB documentation is similar to the JSON (JavaScript Object Notation, Lightweight Data Interchange Format) object. Field values can contain other documents, arrays, and document arrays.
- FIG. 5 provides a data query method for the above scenario, and the process flow is as follows:
- the application server acquires a data model of data to be stored.
- the application server acquires a data model of the data to be stored.
- the data to be stored is ⁇ title:'blog',by:'user',content:'hello world' ⁇
- the data model is ⁇ blogData: ⁇ title:'String',by:'String' ,content:'String' ⁇ .
- the application server obtains ⁇ blogData: ⁇ title:'String',by:'String',content:'String' ⁇ .
- the application server sends the data model to the database server.
- the data model obtained in step 501 needs to be known by the database server, so that the database server establishes a corresponding database. Therefore, the application server sends the data model obtained in step 501 to the database server.
- This embodiment does not limit the specific method in which the application server sends the data model to the database server. For example: Send a data model to the database server by attaching a script.
- the database server receives the data model sent by the application server, and defines a database model according to the data model;
- the database server defines the database model according to the data model to store the data to be stored.
- the database server defines a database model based on a data model, and each database model corresponds to a table in mongoDB.
- the database server may also include a database model manager specifically for storing the database model in the database server.
- the database model is similar to a JSON string object.
- create a database model manager to uniformly find or manage the database model in the mongoDB library.
- the database server By performing steps 501 to 503, the database server establishes a database matching the data to be stored, and the database model of the database is the same as the data model of the data to be stored.
- Steps 501 to 503 can be performed in other cases, except when the data query method provided in this embodiment is executed for the first time. For example, when the application server detects that the data model of the data to be stored changes, step 501 to step 503 are triggered. For another example, when the database server detects that the database model does not match the data model of the data to be stored, step 501 to step 503 are triggered. This embodiment does not limit the specific triggering conditions of step 501 to step 503.
- the database server establishes an association relationship between the database model and the application server.
- the first implementation manner the database server issues a database model to the application server;
- the database server may directly issue a database model to the application server, or may issue an identifier of the database model to the application server.
- the identifier of the database model includes, but is not limited to, the name of the database model.
- the database server determines the interface configuration parameter of the database model, and publishes the interface configuration parameter to the application server;
- the database server defines the interface configuration parameters of the database model, and the data query script generated by the application server can be configured to access the database through the interface configuration parameter and the database model corresponding to the database model.
- the interface configuration parameter can be a public variable.
- interface configuration parameters defined by the database server vary with the implementation. E.g:
- the database access operation contains basic creation, deletion, update, insertion and query, these operations are defined by the original operation instructions of mongoDB.
- these pre-made scripts can be written like the local program to achieve the permission on the database server. The effect of database analysis and calculations. Therefore, the database server must define interface configuration parameters for the following interfaces for the script:
- Database connection interface including the creation, deletion, insertion, update and query functions of documents in the database, providing an access interface of the data model
- the basic javascript base library interface provides the runtime environment for basic data analysis such as calculation and filtering of data.
- the third implementation manner the database server issues a database model to the application server, and the database server determines interface configuration parameters of the database model, and issues interface configuration parameters to the application server.
- the application server acquires a database model and/or an interface configuration parameter from the data storage system.
- the database model and/or interface configuration parameters may be connected to the database corresponding to the database model, and the database is accessed and operated based on the connection.
- the application server obtains the corresponding database connection by using the database model identifier, and the database table is Read and write.
- a database connection is established between the application server and the database server. Based on the connection, the application server can access the corresponding database and operate on the data in the database.
- the application server After the terminal initiates the query request, the application server obtains the data query request, and generates a data query script according to the data query request.
- the application server generates a data query script according to the database model and/or interface configuration parameters from the data storage system acquired in step 505.
- the data query script includes but is not limited to: a data query statement and a result analysis statement.
- the result analysis statement includes but is not limited to: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the application server generates a data query script according to the database model and/or interface configuration parameters from the data storage system acquired in step 505, and forms the following data query script:
- 1), 2), 4) are data query statements, and 3) are result analysis statements.
- script content is only an example.
- script content the script form, and the language used by the script can be adaptively changed. This embodiment does not limit the specific script content, form, and usage language.
- the application server sends the data query script to the database server;
- the application server sends a data query script to the database server using a structured query language.
- the database server executes the data query script, obtains the data query result, and feeds back the data query result to the application server;
- the data query script includes but is not limited to: a data query statement and a result analysis statement.
- the result analysis statement includes but is not limited to: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the database server first queries all contacts that talk to the terminal; then finds the last message in conversation with each contact; then sorts the last message of each contact conversation in chronological order, determining the final The contact with the terminal; finally the information of the last contact with the user.
- the process of querying the data can also be implemented as follows:
- the database server can support dynamic loading of language or library classes.
- javascript it supports the use of eval to dynamically load data query scripts, while java also supports loader query scripts in class loader mode, but needs to be performed. Precompiled.
- the database server of different languages and frameworks is dynamically loaded.
- the Node server used in this embodiment has a mechanism for loading dynamic modules.
- the application server only needs to write the data query script as a text file and send it to the database server. After the database server receives it, it is loaded as a module.
- the database server script In addition, in order to ensure the security of the data query script, the database server script must be verified before the script is loaded to prevent dangerous code injection.
- the application server receives the result obtained by the database server executing the data query script.
- the database server executes the data query script instead of the general query language, thereby optimizing the data access process and reducing the frequent network communication with the database server. In this way, data analysis and filtering operations can be performed simultaneously while the database server is running and the operation results can be flexibly given.
- the overall process of the method is: 1) application server application deployment; 2) application server application initialization; 3) application server definition data model; 4) application The server confirms whether there is a data model in the database server, if it does not exist, executes 5), if it exists, executes 6); 5) the application server sends the data model to the database server side; 6) the application server acquires the configuration from the database server, The configuration includes, but is not limited to, a database model and/or interface configuration parameters; 7) the application server sends a data query script to the database server; 8) the application server determines whether the query is finished, if it is finished, executes 9), and if not, executes 7 ); 9) Application server output results.
- the above method directly puts part of the data analysis and processing operations on the database server, solves the problem that the database access query in the database server is inconvenient, and expands the execution mode of the database operation.
- the implementation process of the existing data query method is as follows: 1) the terminal sends a query request to the application server; 2) the application server processes the query request; 3) the application server sends a data request to the database server according to the query request; 4)
- the database server parses the data request, determines the query content; 5) the database server performs the query based on the memory; 6) the memory performs the database access to obtain the query data; 7) the memory returns the data to the database server; 8) the database server returns the data to the application server; 9)
- the application server analyzes the returned data; 10) the application server sends the data request to the database server again according to the analysis result; 11) the database server parses the data request, determines the query content; 12) the database server performs the query based on the memory; 13) the memory performs the database access Query data; 14) the memory returns data to the database server; 15) the database server returns data to the application server; 16) the application server analyzes the returned data to obtain the final result; 17) the application
- the implementation process of the data query method provided by this embodiment is as follows: 1) the terminal sends a service request to the application server; 2) the application server processes the service request; 3) the application server constructs the data query script; 4) the application server The database server sends the data query script; 5) the database server loads the data query script; 6) the database server executes the data query script; 7) the memory performs the database access to obtain the query data; 8) the memory returns the data to the database server; 9) the database server according to the memory
- the returned data is analyzed for data; 10) the database server executes the query again based on the memory; 11) the memory performs database access to obtain the query data; 12) the memory returns data to the database server; 13) the database server returns data to the application server; 14) the application server Analyze the returned data to get the final result; 15) The application server returns the final result to the terminal.
- the existing implementation process can only be implemented in the application server, obtain a rough result by querying the database, and then return to the application server program to run the screening or analysis processing, and finally according to the running result. Perform the next query operation.
- the data query method proposed in this embodiment directly sends the data query script as part of the query request to the data server, and the database server executes the data query script to query from the database and calculate the final data to be returned to the application server.
- the application server the developer only needs to implement the preparation data query script and query Dynamically modify these data query scripts when they occur, and send them to the database server through the database query port.
- the database server directly returns the results of the data query script execution, thereby avoiding frequent network access problems. For a system distributed remotely, it saves a lot of network communication delay time and alleviates the computing pressure of the local application server in processing the query results returned by the network.
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- the data storage system's own concurrency capability can be utilized to improve data query efficiency.
- the embodiment does not limit the specific implementation manner of the data storage system concurrency.
- the data storage system is composed of middleware and a database server, and the data query script is distributed by the middleware to implement concurrent execution of the data storage system.
- the middleware distributes the data query script
- the data query script is split by the middleware to optimize the data query sequence, thereby optimizing the database access process. , reduce the number of readings and reading range of the database, optimize the operation efficiency.
- FIG. 9 The embodiment shown in FIG. 9 is exemplified by the following specific scenarios. For other scenarios, refer to the implementation of the following scenarios.
- the data storage system consists of middleware and one or more database servers.
- the application server acquires a data model of data to be stored.
- step 501 The implementation of this step is the same as that of step 501.
- step 501 For details, refer to step 501, and details are not described herein again.
- the application server sends the data model to the database server.
- step 502. The implementation of this step is the same as that of step 502. For details, refer to step 502, and details are not described herein again.
- the database server receives the data model sent by the application server, and defines a database model according to the data model.
- the database server can directly receive the data model sent by the application server, or receive the data model sent by the application server through the middleware.
- the database server establishes a database matching the data to be stored, and the database model of the database is the same as the data model of the data to be stored.
- Steps 901 to 903 can be performed in other cases, except when the data query method provided in this embodiment is executed for the first time. For example, when the application server detects that the data model of the data to be stored changes, step 901 to step 903 are triggered. For example, when the database server detects that the database model does not match the data model of the data to be stored, step 901 to step 903 are triggered. This embodiment does not limit the specific trigger conditions for performing steps 901 to 903.
- the database server establishes an association relationship between the database model and the application server.
- the first implementation manner the database server issues a database model to the application server;
- the database server determines the interface configuration parameter of the database model, and publishes the interface configuration parameter to the application server;
- the third implementation manner the database server issues a database model to the application server, and the database server determines interface configuration parameters of the database model, and issues interface configuration parameters to the application server.
- the database server may directly publish the database model to the application server, or may publish the database model to the application server through the middleware.
- the database server can directly publish interface configuration parameters to the application server, and can also publish interface configuration parameters to the application server through the middleware.
- the application server acquires a database model and/or an interface configuration parameter from the data storage system.
- the application server can directly obtain the database model and/or interface configuration parameters from the data storage system, and can also obtain the database model and/or interface configuration parameters from the data storage system through the middleware.
- the application server After the terminal initiates the query request, the application server obtains a data query request, and generates a data query script according to the data query request.
- step 506 The implementation of this step is the same as that of step 506. For details, refer to step 506, and details are not described herein again.
- the application server sends the data query script to the middleware
- the middleware acquires a data query script from the application server, and after determining one or more database servers that execute the data query script, distributes the data query script to the database server;
- the middleware can obtain the data stored by each database server, select a database server that executes the data query script, and distribute a data query script to each selected database server.
- the data query script is: query all voice contacts that talk to the user's voice and all text messages that are in conversation with the user's text message.
- the database server 11 and the database server 12 If there are two database servers storing voice call data, the database server 11 and the database server 12, wherein the database server 11 stores the voice contacts of the user 0-100, and the database server 12 stores the voice contacts of the user 100-200. people.
- This step distributes the data query script to the database server 11, database server 12, database server 21, and database server 22. That is, a data query script is sent to the database server 11, a data query script is sent to the database server 12, a data query script is sent to the database server 21, and a data query script is sent to the database server 22.
- the database server obtains the data query script distributed by the middleware based on the data query script from the application server, executes the distributed data query script, obtains the data query result, and feeds back the data query result to the middleware;
- the database server can determine which parts of the data query script are executable by the database server based on the data it stores, and which parts do not need to be executed. After the database server obtains the data query script distributed by the middleware based on the data query script from the application server, it executes the part of the distributed data query script that it thinks needs to be executed.
- the data query script is as follows: Query the voice conversation with the user and all the contacts who talk to the user SMS.
- the database server 11 which stores the voice contacts of the user number 0-100, can therefore perform a voice contact number 0-100 that queries the user's voice conversation.
- the database server 11 executes only in the voice contact number 0-100, queries the language contact part of the conversation with the user voice, does not execute in the voice contact number 101-200, queries the voice contact part of the conversation with the user voice and the query All SMS contact sections that are in conversation with the user's text message. After obtaining the data query result for the voice contact number 0-100, the data query result is fed back to the middleware.
- the database server 12 stores the voice contacts of the user number 101-200, so that it can execute the query Voice contact number 101-200 in conversation with the user voice.
- the database server 12 executes only in the voice contact number 101-200, queries the language contact part of the conversation with the user voice, does not execute in the voice contact number 0-100, queries the voice contact part of the conversation with the user voice and the query All SMS contact sections that are in conversation with the user's text message. After obtaining the data query result for the voice contact number 101-200, the data query result is fed back to the middleware.
- the database server 21 stores the short message contacts of the user 0-100, so that it can execute the SMS-number 0-100 contact that queries the user's short message.
- the database server 11 executes only the short message contact in the 0-100 number, queries the short message contact part of the short message conversation with the user, does not execute in the short message contact number 101-200, and queries the short message contact part of the short message conversation with the user and the query. All voice contact sections that talk to the user's voice. After obtaining the data query result for the SMS contact number 0-100, the data query result is fed back to the middleware.
- the database server 22 stores the short message contacts of the user No. 101-200, and therefore, it can execute the short message contacts No. 101-200 for inquiring the short message with the user.
- the database server 22 only executes the short message contact part in the short message contact number 101-200, and queries the short message contact part of the short message conversation with the user, does not execute the short message contact part in the 0-100 number, and queries the short message contact part of the short message conversation with the user and the query. All voice contact sections that talk to the user's voice. After obtaining the data query result for the short message contact number 101-200, the data query result is fed back to the middleware.
- the process of querying the data may first determine whether it has cached related data, and if the cache has been cached, and the cache has not expired, the cached data is obtained, thereby obtaining the cached data. Save database access.
- the middleware obtains the data query result fed back by the database server, and sends the data query result to the application server;
- the middleware of the step obtains the data query result fed back by each database server, summarizes the data query results, and sends the summarized result to the application server.
- the specific way of summarizing can be the superposition of the data query results fed back by each database server.
- the middleware obtains the data query result for the voice contact number 0-100 fed back by the database server 11, the data query result for the voice contact of the number 101-200 fed back by the database server 12, and the feedback from the database server 21 for 0-100.
- the above four results are superimposed together to obtain the data query result of the voice contact 0-200 and
- the data query result of the SMS contact number 0-200 sends the data query result of the voice contact 0-200 and the data query result of the voice contact 0-200 to the application server.
- the application server receives the result of the middleware transmission.
- the terminal sends a service request to the application server; 2) the application server processes the service request; 3) the application server sends a configuration query request to the middleware; 4) the middleware query configuration, and returns the query configuration, the configuration Including but not limited to database model and/or interface configuration parameters; 5) application server builds data query script according to the configuration; 6) application server sends data query script to middleware; 7) middleware distributes data query script; 8) distributes to The database server of the data query script executes the query based on the data query script; 9) the database server returns the execution result to the middleware; 10) the database server summarizes the execution result and returns the summarized result to the application server; 11) the application server analyzes the returned summary result, The final result is obtained; 15) the application server returns the final result to the terminal.
- the required results can be searched more accurately and intelligently in the database.
- the burden of the database server can also be reduced by distributing the operations in different databases.
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- the embodiment provides an application server.
- the principle of the application server is similar to the data query method shown in FIG. 2, so the implementation of the application server can refer to the method shown in FIG. The embodiments are not repeated here.
- the application server includes:
- the first obtaining module 1101 is configured to obtain a data query request.
- a generating module 1102 configured to generate a data query script according to the data query request acquired by the first obtaining module 1101;
- the first sending module 1103 is configured to send the data query script generated by the generating module 1102 to the data storage system;
- the receiving module 1104 is configured to receive a result obtained by the data storage system executing the data query script sent by the first sending module 1103.
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or Any combination of the above.
- the generating module 1102 is configured to obtain a database model and/or an interface configuration parameter from the data storage system, and generate a data query script according to the database model and/or the interface configuration parameter.
- the application server further includes:
- a second obtaining module 1105 configured to acquire a data model of data to be stored
- the second sending module 1106 is configured to send the data model acquired by the second obtaining module 1105 to the data storage system, so that the data storage system defines the database model according to the data model.
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- the embodiment provides a database server.
- the principle of solving the problem is similar to the data query method shown in FIG. 3, so the implementation of the database server can be referred to the method shown in FIG. The embodiments are not repeated here.
- the database server includes:
- An obtaining module 1301, configured to acquire a data query script from an application server
- the execution module 1302 is configured to execute the data query script acquired by the obtaining module 1301 to obtain a data query result.
- the feedback module 1303 is configured to feed back the data query result obtained by the execution module 1302 to the application server.
- the data query script includes a data query statement and a result analysis statement.
- the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
- the obtaining module 1301 is configured to obtain a data query script that is distributed by the middleware based on a data query script from an application server.
- the feedback module 1303 is configured to feed back the data query result to the application server by using the middleware.
- the database server further includes:
- the receiving module 1304 is configured to receive a data model sent by the application server.
- a definition module 1305, configured to define a database model according to a data model received by the receiving module 1304;
- the establishing module 1306 is configured to establish a relationship between the database model defined by the definition module 1305 and the application server. Linkage.
- the establishing module 1306 is configured to issue a database model to the application server, and/or determine interface configuration parameters of the database model, and issue interface configuration parameters to the application server.
- the application server After the application server generates the data query script according to the data query request, the data query script is executed, and the result obtained by the execution script is fed back to the application server, so that only the receiving application server sends the data query script, and the final result can be obtained according to the data query script.
- the number of accesses with the application server is reduced, and data query efficiency is improved.
- the present embodiment provides a middleware. Since the principle of solving the problem is similar to the data query method shown in FIG. 4, the implementation of the middleware can be referred to the method shown in FIG. The embodiments are not repeated here.
- the middleware includes:
- a first obtaining module 1501 configured to acquire a data query script from an application server
- a determining module 1502 configured to determine one or more database servers that execute the data query script acquired by the first obtaining module 1501;
- the sending module 1503 is configured to distribute the data query script acquired by the first obtaining module 1502 to the database server;
- a second obtaining module 1504 configured to obtain a data query result fed back by the database server
- the sending module 1505 is configured to send the data query result obtained by the second obtaining module 1504 to the application server.
- the middleware After the middleware obtains the data query script generated by the application server according to the data query request, the data query script is distributed to the database server, so that the database server executes the distributed data query script, and the data query result returned by the database server is sent to the application server, so that only The application server needs to send a data query script to obtain data according to the data query script and analyze the data to obtain the result, thereby reducing the number of accesses with the application server and improving the data query efficiency.
- the present embodiment provides a data query system for performing the data query method provided by the embodiment shown in FIG. 5 or FIG. 6.
- the system includes: an application server 1601 and data. Storage system 1602;
- the application server 1601 is an application server as shown in FIG. 11 or FIG. 12;
- the data storage system 1602 is composed of a database server as shown in FIG. 13 or FIG. 14, or the data storage system 1602 is composed of a database server as shown in FIG. 13 or FIG. 14 and a middleware as shown in FIG.
- Obtaining a data query request generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed.
- the system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
- embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
- computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
- the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
- the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
- These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
- the instructions are provided for implementing one or more processes and/or block diagrams in the flowchart The steps of a function specified in a box or multiple boxes.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
Description
本申请涉及数据库技术领域,尤其涉及数据查询方法、应用和数据库服务器、中间件及系统。The present application relates to the field of database technologies, and in particular, to data query methods, applications, and database servers, middleware, and systems.
数据库是依照某种数据模型组织起来并存放二级存储器中的数据集合。这种数据集合具有如下特点:尽可能不重复,以最优方式为某个特定组织的多种应用服务,其数据结构独立于使用它的应用程序,对数据的增、删、改、查由统一软件进行管理和控制。因此,数据库为使用它的应用程序提供基础数据资源,对数据库中数据的查询效果直接影响使用它的应用程序的运行效果。A database is organized according to a data model and stores a collection of data in secondary storage. This data set has the following characteristics: it does not repeat as much as possible, and optimally serves multiple applications of a specific organization. Its data structure is independent of the application that uses it, and the data is added, deleted, modified, and checked. Unified software for management and control. Therefore, the database provides the underlying data resources for the application that uses it, and the query effect on the data in the database directly affects the performance of the application that uses it.
以在一个聊天应用中,用户如果需要查询最后与自己对话的联系人信息为例,目前数据查询方法为:聊天应用的应用服务器在获取用户的该查询请求后,首先,第一次向数据库发起查询请求,以查询与用户对话的所有联系人;其次,第二次向数据库发起查询请求,以查找与每个联系人对话的最后一条消息;最后,按时间顺序对每个联系人对话的最后一条消息进行排序,确定最后与用户对话的联系人后,第三次向数据库发起查询请求,以查询最后与用户对话的联系人的信息,并将该联系人信息反馈给该用户。In a chat application, if the user needs to query the contact information that is finally in conversation with the user, the current data query method is: after the application server of the chat application obtains the query request of the user, firstly, the first time is initiated to the database. Query the request to query all contacts who talk to the user; secondly, the second time a query request is initiated to the database to find the last message in conversation with each contact; finally, the last of each contact in chronological order After a message is sorted, the last contact with the user is determined, and a query request is initiated to the database for the third time to query the information of the last contact with the user, and the contact information is fed back to the user.
在这个过程中需要对数据库服务器进行3次访问,并且需要传输大量数据到客户端,供客户端筛选后再次执行查询,效率较低。In this process, the database server needs to be accessed 3 times, and a large amount of data needs to be transmitted to the client for the client to perform the query again after filtering, which is inefficient.
发明内容Summary of the invention
为了提高查询效率,本申请实施例提出了一种数据查询方法、应用和数据库服务器、中间件及系统。In order to improve query efficiency, the embodiment of the present application proposes a data query method, an application, a database server, a middleware, and a system.
第一方面,本申请实施例提供了一种数据查询方法,所述方法包括:In a first aspect, an embodiment of the present application provides a data query method, where the method includes:
获取数据查询请求,根据所述数据查询请求生成数据查询脚本;Obtaining a data query request, and generating a data query script according to the data query request;
将所述数据查询脚本发送至数据存储系统;Sending the data query script to a data storage system;
接收所述数据存储系统执行所述数据查询脚本得到的结果。Receiving a result obtained by the data storage system executing the data query script.
可选地,所述数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,所述结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句, 或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, Or any combination of the above.
可选地,所述根据数据查询请求生成数据查询脚本,包括:Optionally, the generating a data query script according to the data query request includes:
获取来自数据存储系统的数据库模型和/或接口配置参数,根据所述数据库模型和/或接口配置参数生成数据查询脚本。Obtaining database model and/or interface configuration parameters from the data storage system, and generating a data query script based on the database model and/or interface configuration parameters.
可选地,所述方法,还包括:Optionally, the method further includes:
获取待存储数据的数据模型;Obtaining a data model of the data to be stored;
将所述数据模型发送至数据存储系统,以使所述数据存储系统根据所述数据模型定义数据库模型。The data model is sent to a data storage system such that the data storage system defines a database model based on the data model.
第二方面,本申请实施例提供了一种应用服务器,所述应用服务器包括:In a second aspect, an embodiment of the application provides an application server, where the application server includes:
第一获取模块,用于获取数据查询请求;a first obtaining module, configured to obtain a data query request;
生成模块,用于根据所述第一获取模块获取的数据查询请求生成数据查询脚本;a generating module, configured to generate a data query script according to the data query request acquired by the first obtaining module;
第一发送模块,用于将所述生成模块生成的数据查询脚本发送至数据存储系统;a first sending module, configured to send a data query script generated by the generating module to a data storage system;
接收模块,用于接收所述数据存储系统执行所述第一发送模块发送的数据查询脚本得到的结果。And a receiving module, configured to receive a result obtained by the data storage system executing a data query script sent by the first sending module.
可选地,所述数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,所述结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,所述生成模块,用于获取来自数据存储系统的数据库模型和/或接口配置参数,根据所述数据库模型和/或接口配置参数生成数据查询脚本。Optionally, the generating module is configured to acquire a database model and/or an interface configuration parameter from the data storage system, and generate a data query script according to the database model and/or the interface configuration parameter.
可选地,所述应用服务器,还包括:Optionally, the application server further includes:
第二获取模块,用于获取待存储数据的数据模型;a second acquiring module, configured to acquire a data model of data to be stored;
第二发送模块,用于将所述第二获取模块获取的数据模型发送至数据存储系统,以使所述数据存储系统根据所述数据模型定义数据库模型。And a second sending module, configured to send the data model acquired by the second acquiring module to the data storage system, so that the data storage system defines the database model according to the data model.
第三方面,本申请实施例提供了一种数据查询方法,所述方法包括:In a third aspect, an embodiment of the present application provides a data query method, where the method includes:
获取来自应用服务器的数据查询脚本;Get the data query script from the application server;
执行所述数据查询脚本,获得数据查询结果;Executing the data query script to obtain a data query result;
将所述数据查询结果反馈至所述应用服务器。The data query result is fed back to the application server.
可选地,所述数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,所述结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。 Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,所述获取来自应用服务器数据查询脚本,包括:Optionally, the obtaining the data query script from the application server comprises:
获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本;Obtaining a middleware based data query script distributed from a data query script from an application server;
所述将数据查询结果反馈至所述应用服务器包括:The feeding back the data query result to the application server includes:
通过所述中间件将所述数据查询结果反馈至所述应用服务器。The data query result is fed back to the application server by the middleware.
可选地,所述方法,还包括:Optionally, the method further includes:
接收所述应用服务器发送的数据模型;Receiving a data model sent by the application server;
根据所述数据模型定义数据库模型;Defining a database model based on the data model;
建立所述数据库模型与所述应用服务器之间的关联关系。Establishing an association relationship between the database model and the application server.
可选地,所述建立所述数据库模型与所述应用服务器之间的关联关系,包括:Optionally, the establishing an association relationship between the database model and the application server includes:
向所述应用服务器发布数据库模型,和/或,确定所述数据库模型的接口配置参数,向所述应用服务器发布所述接口配置参数。Publishing a database model to the application server, and/or determining interface configuration parameters of the database model, and publishing the interface configuration parameters to the application server.
第四方面,本申请实施例提供了一种数据库服务器,所述数据库服务器包括:In a fourth aspect, an embodiment of the present application provides a database server, where the database server includes:
获取模块,用于获取来自应用服务器的数据查询脚本;An obtaining module, configured to obtain a data query script from an application server;
执行模块,用于执行所述获取模块获取的数据查询脚本,获得数据查询结果;An execution module, configured to execute a data query script obtained by the obtaining module, to obtain a data query result;
反馈模块,用于将所述执行模块获得的数据查询结果反馈至所述应用服务器。And a feedback module, configured to feed back the data query result obtained by the execution module to the application server.
可选地,所述数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,所述结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,所述获取模块,用于获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本;Optionally, the obtaining module is configured to obtain a data query script that is distributed by the middleware based on a data query script from an application server;
所述反馈模块,用于通过所述中间件将所述数据查询结果反馈至所述应用服务器。The feedback module is configured to feed back the data query result to the application server by using the middleware.
可选地,所述数据库服务器,还包括:Optionally, the database server further includes:
接收模块,用于接收所述应用服务器发送的数据模型;a receiving module, configured to receive a data model sent by the application server;
定义模块,用于根据所述接收模块接收的数据模型定义数据库模型;a definition module, configured to define a database model according to a data model received by the receiving module;
建立模块,用于建立所述定义模块定义的数据库模型与所述应用服务器之间的关联关系。And establishing a module, configured to establish an association relationship between the database model defined by the definition module and the application server.
可选地,所述建立模块,用于向所述应用服务器发布数据库模型,和/或,确定所述数据库模型的接口配置参数,向所述应用服务器发布所述接口配置参数。Optionally, the establishing module is configured to issue a database model to the application server, and/or determine an interface configuration parameter of the database model, and issue the interface configuration parameter to the application server.
第五方面,本申请实施例提供了一种数据查询方法,所述方法包括:In a fifth aspect, an embodiment of the present application provides a data query method, where the method includes:
获取来自应用服务器的数据查询脚本; Get the data query script from the application server;
确定执行所述数据查询脚本的一个或多个数据库服务器;Determining one or more database servers executing the data query script;
将所述数据查询脚本分发至所述数据库服务器;Distributing the data query script to the database server;
获得所述数据库服务器反馈的数据查询结果,并将所述数据查询结果发送至所述应用服务器。Obtaining a data query result fed back by the database server, and sending the data query result to the application server.
第六方面,本申请实施例提供了一种中间件,所述中间件包括:In a sixth aspect, an embodiment of the present application provides a middleware, where the middleware includes:
第一获取模块,用于获取来自应用服务器的数据查询脚本;a first obtaining module, configured to acquire a data query script from an application server;
确定模块,用于确定执行所述第一获取模块获取的数据查询脚本的一个或多个数据库服务器;a determining module, configured to determine one or more database servers that execute the data query script acquired by the first obtaining module;
发送模块,用于将所述第一获取模块获取的数据查询脚本分发至所述数据库服务器;a sending module, configured to distribute the data query script acquired by the first acquiring module to the database server;
第二获取模块,用于获得所述数据库服务器反馈的数据查询结果;a second obtaining module, configured to obtain a data query result fed back by the database server;
发送模块,用于将所述第二获取模块获取的数据查询结果发送至所述应用服务器。And a sending module, configured to send the data query result obtained by the second acquiring module to the application server.
第七方面,本申请实施例提供了一种数据查询系统,述系统包括:应用服务器和数据存储系统;In a seventh aspect, the embodiment of the present application provides a data query system, where the system includes: an application server and a data storage system;
其中,所述应用服务器如上述第二方面所述的应用服务器;The application server, such as the application server described in the second aspect above;
所述数据存储系统由如上述第四方面所述的数据库服务器组成,或者,所述数据存储系统由如上述第四方面所述的数据库服务器和如上述第六方面所述的中间件组成。The data storage system is composed of the database server according to the above fourth aspect, or the data storage system is composed of the database server according to the above fourth aspect and the middleware as described in the sixth aspect above.
有益效果如下:The benefits are as follows:
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
下面将参照附图描述本申请的具体实施例,其中:Specific embodiments of the present application will be described below with reference to the accompanying drawings, in which:
图1示出了本申请一实施例提供的一种数据查询方法的实施环境示意图;FIG. 1 is a schematic diagram of an implementation environment of a data query method according to an embodiment of the present application;
图2示出了本申请另一实施例提供的一种数据查询方法的流程示意图;FIG. 2 is a schematic flowchart diagram of a data query method according to another embodiment of the present application;
图3示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 3 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图4示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 4 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图5示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 5 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图6示出了本申请另一实施例提供的另一种数据查询方法的流程示意图; FIG. 6 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图7示出了本申请另一实施例提供的一种现有数据查询方法的流程示意图;FIG. 7 is a schematic flowchart diagram of an existing data query method according to another embodiment of the present application;
图8示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 8 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图9示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 9 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图10示出了本申请另一实施例提供的另一种数据查询方法的流程示意图;FIG. 10 is a schematic flowchart diagram of another data query method according to another embodiment of the present application;
图11示出了本申请另一实施例提供的一种应用服务器的结构示意图;FIG. 11 is a schematic structural diagram of an application server according to another embodiment of the present disclosure;
图12示出了本申请另一实施例提供的另一种应用服务器的结构示意图;FIG. 12 is a schematic structural diagram of another application server according to another embodiment of the present disclosure;
图13示出了本申请另一实施例提供的一种数据库服务器的结构示意图;FIG. 13 is a schematic structural diagram of a database server according to another embodiment of the present application;
图14示出了本申请另一实施例提供的另一种数据库服务器的结构示意图;FIG. 14 is a schematic structural diagram of another database server according to another embodiment of the present application;
图15示出了本申请另一实施例提供的一种中间件的结构示意图;FIG. 15 is a schematic structural diagram of an intermediate member according to another embodiment of the present application;
图16示出了本申请另一实施例提供的一种数据查询系统的结构示意图。FIG. 16 is a schematic structural diagram of a data query system according to another embodiment of the present application.
为了使本申请的技术方案及优点更加清楚明白,以下结合附图对本申请的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本申请的一部分实施例,而不是所有实施例的穷举。并且在不冲突的情况下,本说明中的实施例及实施例中的特征可以互相结合。The exemplary embodiments of the present application are further described in detail below with reference to the accompanying drawings, in which the embodiments described are only a part of the embodiments of the present application, but not all embodiments. An exhaustive example. And in the case of no conflict, the features in the embodiments and the embodiments in the description can be combined with each other.
参见图1,为本发明实施例提供的数据查询方法的实施环境示意图。该实施环境包括终端101、应用服务器102和数据存储系统103。FIG. 1 is a schematic diagram of an implementation environment of a data query method according to an embodiment of the present invention. The implementation environment includes a terminal 101, an
其中,终端101用于向应用服务器102发送查询请求,接收应用服务器102根据该查询请求得到的结果;The terminal 101 is configured to send a query request to the
应用服务器102,在获取到终端101的查询请求后,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统103;接收数据存储系统103执行数据查询脚本得到的结果,向终端101反馈该结果;After obtaining the query request from the terminal 101, the
数据库模型为应用服务器从数据存储系统获取的,该数据库模型可以包括数据存储系统的数据结构,也可以包括数据存储系统的数据结构和数据操作方式。The database model is obtained from the data storage system by the application server. The database model may include the data structure of the data storage system, and may also include the data structure and data operation mode of the data storage system.
脚本是使用一种特定的描述性语言,依据一定的格式编写的可执行文件,又称作宏或批处理文件。数据查询脚本中可以包括数据查询语句以及结果分析语句,其中结果分析语句可以为结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。A script is an executable file, also called a macro or batch file, written in a specific descriptive language according to a certain format. The data query script may include a data query statement and a result analysis statement, wherein the result analysis statement may be a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
数据存储系统103,可以有2种实现方式:
The
第1种方式,数据存储系统103由一台或多台数据库服务器组成,该数据服务器包括存储器,存储器中存储有数据库。数据库服务器获取来自应用服务器102的数据查询脚本后,执行该数据查询脚本,获得数据查询结果,并将数据查询结果反馈至应用服务器102。In the first mode, the
第2种方式,数据存储系统103由中间件和一台或多台数据库服务器组成,其中,数据服务器包括存储器,存储器中存储有数据库。In the second mode, the
由于中间件可以管理数据库服务器资源和网络通讯,其可以连接多个数据库服务器,即使多个数据库服务器具有不同的接口,但通过中间件相互之间仍能交换信息。因此,中间件获取到来自应用服务器的数据查询脚本后,确定执行数据查询脚本的一个或多个数据库服务器;将数据查询脚本分发至数据库服务器;获得数据库服务器反馈的数据查询结果,并将数据查询结果发送至应用服务器。Because middleware can manage database server resources and network communication, it can connect to multiple database servers. Even if multiple database servers have different interfaces, they can still exchange information with each other through middleware. Therefore, after obtaining the data query script from the application server, the middleware determines one or more database servers that execute the data query script; distributes the data query script to the database server; obtains the data query result fed back by the database server, and queries the data The result is sent to the application server.
数据库服务器获取中间件分发的数据查询脚本后,执行该数据查询脚本,获得数据查询结果,并将数据查询结果反馈至中间件。After obtaining the data query script distributed by the middleware, the database server executes the data query script, obtains the data query result, and feeds back the data query result to the middleware.
同时,数据库服务器在具体实现时,可以仅存储数据,也可以为存储数据的同时和缓存部分数据,本申请不对数据库的具体实现方式进行限定。At the same time, the database server may store only data, and may also store data at the same time and cache part of the data. This application does not limit the specific implementation of the database.
结合上述实施环境,参见图2所示的实施例,本实施例提供了一种数据查询方法,本实施例提供的方法流程具体如下:With reference to the foregoing implementation environment, referring to the embodiment shown in FIG. 2, this embodiment provides a data query method. The process of the method provided in this embodiment is as follows:
201:获取数据查询请求,根据数据查询请求生成数据查询脚本;201: Acquire a data query request, and generate a data query script according to the data query request;
可选地,数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,根据数据查询请求生成数据查询脚本,包括:Optionally, generating a data query script according to the data query request, including:
获取来自数据存储系统的数据库模型和/或接口配置参数,根据数据库模型和/或接口配置参数生成数据查询脚本。Obtain database model and/or interface configuration parameters from the data storage system and generate data query scripts based on database model and/or interface configuration parameters.
202:将数据查询脚本发送至数据存储系统;202: Send a data query script to the data storage system;
203:接收数据存储系统执行数据查询脚本得到的结果。203: Receive a result obtained by the data storage system executing a data query script.
可选地,该方法,还包括:Optionally, the method further includes:
获取待存储数据的数据模型;Obtaining a data model of the data to be stored;
将数据模型发送至数据存储系统,以使数据存储系统根据数据模型定义数据库模型。 The data model is sent to a data storage system to enable the data storage system to define a database model based on the data model.
参见图3,本实施例提供了另一种数据查询方法,该方法流程具体如下:Referring to FIG. 3, this embodiment provides another data query method, and the process of the method is specifically as follows:
301:获取来自应用服务器的数据查询脚本;301: Acquire a data query script from an application server;
可选地,数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,获取来自应用服务器数据查询脚本,包括:Optionally, obtaining a data query script from the application server, including:
获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本;Obtaining a middleware based data query script distributed from a data query script from an application server;
将数据查询结果反馈至应用服务器包括:Feedback of the data query results to the application server includes:
通过中间件将数据查询结果反馈至应用服务器。The data query results are fed back to the application server through the middleware.
302:执行数据查询脚本,获得数据查询结果;302: executing a data query script to obtain a data query result;
303:将数据查询结果反馈至应用服务器。303: Feed the data query result to the application server.
可选地,该方法,还包括:Optionally, the method further includes:
接收应用服务器发送的数据模型;Receiving a data model sent by the application server;
根据数据模型定义数据库模型;Define a database model based on the data model;
建立数据库模型与应用服务器之间的关联关系。Establish an association between the database model and the application server.
可选地,建立数据库模型与应用服务器之间的关联关系,包括:Optionally, establishing an association between the database model and the application server, including:
向应用服务器发布数据库模型,和/或,确定数据库模型的接口配置参数,向应用服务器发布接口配置参数。Publish the database model to the application server, and/or determine the interface configuration parameters of the database model and publish the interface configuration parameters to the application server.
参见图4,本实施例提供了再一种数据查询方法,该方法流程具体如下:Referring to FIG. 4, this embodiment provides another data query method, and the process flow is as follows:
401:获取来自应用服务器的数据查询脚本;401: Obtain a data query script from an application server;
402:确定执行数据查询脚本的一个或多个数据库服务器;402: Determine one or more database servers that execute the data query script;
403:将数据查询脚本分发至数据库服务器;403: Distribute the data query script to the database server;
404:获得数据库服务器反馈的数据查询结果,并将数据查询结果发送至应用服务器。404: Obtain a data query result fed back by the database server, and send the data query result to the application server.
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。 Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
结合上述实施环境,本申请提供了一种数据查询方法。本申请提供的方法可以应用于各种业务中,尤其是数据密集型应用中查询需求复杂的应用场景,可以打破数据库访问量瓶颈,解决运算密集的实时数据库访问问题。In combination with the above implementation environment, the present application provides a data query method. The method provided by the present application can be applied to various services, especially application scenarios with complex query requirements in data-intensive applications, which can break the database access bottleneck and solve the computationally intensive real-time database access problem.
为了更清楚明确的说明本实施例提供的数据展示方法,本实施例以如下具体场景为例,对于其他场景,可参见如下场景的实现方式。For a clearer and more explicit description of the data display method provided in this embodiment, the following specific scenarios are taken as an example in the following embodiments. For other scenarios, refer to the implementation manner of the following scenarios.
具体场景:在一个聊天应用中,终端通过结构化查询语言查询最后对话的联系人信息,数据存储系统为数据库服务器。Specific scenario: In a chat application, the terminal queries the contact information of the last conversation through a structured query language, and the data storage system is a database server.
其中,结构化查询语言,是一种特殊目的的编程语言,是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统。Among them, structured query language is a special purpose programming language, which is a database query and programming language for accessing data and querying, updating and managing relational database systems.
数据库服务器,在接收数据查询脚本后,通过后端的一个单独隔离出的线程加载该脚本,并赋予数据查询脚本读取数据库权限后,按照一定顺序执行数据查询脚本。数据查询脚本可以访问数据库服务器上的数据库,处理数据,当数据处理完成时,通知返回处理结果。After receiving the data query script, the database server loads the script through a separately isolated thread of the backend, and after the data query script is given the database permission, the data query script is executed in a certain order. The data query script can access the database on the database server, process the data, and when the data processing is completed, the notification returns the processing result.
另外,该场景中数据库服务器的实现方式有多种,本实施例仅以Node(节点)服务器,结合mongoDB数据库引擎组成的数据库服务器为例进行说明。具体的,数据库服务器接收javascript形式的数据查询脚本,动态加载脚本并按照数据查询脚本的描述对数据库进行查询。In addition, there are various implementations of the database server in this scenario. In this embodiment, only the Node server and the database server composed of the mongoDB database engine are taken as an example for description. Specifically, the database server receives the data query script in the form of javascript, dynamically loads the script, and queries the database according to the description of the data query script.
其中,Node服务器是一种使用javascript编写的开源跨平台运行环境,采用google的V8引擎执行代码,由于javascript本身是一种脚本语言,可以动态地加载脚本片段进行执行,并在运行时对脚本执行进行修改。Among them, the Node server is an open source cross-platform running environment written in javascript, using Google's V8 engine to execute code. Since javascript itself is a scripting language, it can dynamically load script fragments for execution and execute scripts at runtime. to modify.
mongoDB是由C++语言编写的,是一个基于分布式文件存储的开源数据库系统。在高负载的情况下,可以通过添加更多的节点,扩展服务器来确保并发性能,mongoDB将数据存储为一个文档,数据结构由键值对(key=>value)(关键字=>值)组成。mongoDB文档类似于JSON(JavaScript Object Notation,轻量级的数据交换格式)对象。字段值可以包含其他文档,数组及文档数组。mongoDB is written in C++ and is an open source database system based on distributed file storage. In the case of high load, you can extend the server to ensure concurrent performance by adding more nodes. MongoDB stores the data as a document, and the data structure is composed of key-value pairs (key=>value) (keyword=>value). . The mongoDB documentation is similar to the JSON (JavaScript Object Notation, Lightweight Data Interchange Format) object. Field values can contain other documents, arrays, and document arrays.
图5提供了针对上述场景的一种数据查询方法,该方法流程具体如下:FIG. 5 provides a data query method for the above scenario, and the process flow is as follows:
501:应用服务器获取待存储数据的数据模型;501: The application server acquires a data model of data to be stored.
应用程序在设计时,会对其待存储的数据结构进行定义,形成数据模型。本步骤中, 应用服务器获取该待存储数据的数据模型。When the application is designed, it defines the data structure to be stored to form a data model. In this step, The application server acquires a data model of the data to be stored.
例如:E.g:
应用程序设计:待存储数据为{title:′blog′,by:′user′,content:′hello world′},则形成的数据模型为{blogData:{title:′String′,by:′String′,content:′String′}}。Application design: The data to be stored is {title:'blog',by:'user',content:'hello world'}, then the data model is {blogData:{title:'String',by:'String' ,content:'String'}}.
应用服务器获取{blogData:{title:′String′,by:′String′,content:′String′}}。The application server obtains {blogData:{title:'String',by:'String',content:'String'}}.
502:应用服务器将数据模型发送至数据库服务器;502: The application server sends the data model to the database server.
步骤501中获取的数据模型需要被数据库服务器得知,以便数据库服务器建立对应的数据库,因此,应用服务器将步骤501中获取的数据模型发送至数据库服务器。The data model obtained in
本实施例不对应用服务器将数据模型发送至数据库服务器的具体方法进行限定。例如:通过附加脚本的方式将数据模型发送至数据库服务器。This embodiment does not limit the specific method in which the application server sends the data model to the database server. For example: Send a data model to the database server by attaching a script.
503:数据库服务器接收应用服务器发送的数据模型,根据数据模型定义数据库模型;503: The database server receives the data model sent by the application server, and defines a database model according to the data model;
由于应用服务器发送的数据模型为待存储数据的数据模型,而待存储数据最终会存储至数据库服务器的数据库中,因此,数据库服务器根据数据模型定义数据库模型,以存储该待存储数据。Since the data model sent by the application server is the data model of the data to be stored, and the data to be stored is finally stored in the database of the database server, the database server defines the database model according to the data model to store the data to be stored.
例如:数据库服务器根据数据模型定义数据库模型,而每个数据库模型在mongoDB中对应一个表。For example, the database server defines a database model based on a data model, and each database model corresponds to a table in mongoDB.
另外,随着数据库服务器存储的数据较多,数据库模型也较杂。为了便于数据库服务器对数据库模型的管理,数据库服务器还可以包括一个数据库模型管理器,专门用来存储数据库服务器中数据库模型。In addition, as the database server stores more data, the database model is also more complicated. In order to facilitate the database server to manage the database model, the database server may also include a database model manager specifically for storing the database model in the database server.
例如在mongoDB实现中,数据库模型类似于一个JSON串对象。在同一个mongoDB库中,建立一个数据库模型管理器,对mongoDB库中的数据库模型进行统一查找或者管理。For example, in the mongoDB implementation, the database model is similar to a JSON string object. In the same mongoDB library, create a database model manager to uniformly find or manage the database model in the mongoDB library.
通过执行步骤501至步骤503,数据库服务器会建立与待存储数据匹配的数据库,该数据库的数据库模型与待存储数据的数据模型相同。By performing
步骤501至步骤503,除在初次执行本实施例提供的数据查询方法时执行外,还可以在其他情况下执行。例如:当应用服务器监测到待存储数据的数据模型发生改变时,触发执行步骤501至步骤503。再例如:数据库服务器监测到数据库模型与待存储数据的数据模型不匹配时,触发执行步骤501至步骤503。本实施例不对执行步骤501至步骤503的具体触发条件进行限定。
504:数据库服务器建立数据库模型与应用服务器之间的关联关系; 504: The database server establishes an association relationship between the database model and the application server.
此步骤的具体实现方式,包括但不限于如下3种。Specific implementations of this step include, but are not limited to, the following three types.
第1种实现方式:数据库服务器向应用服务器发布数据库模型;The first implementation manner: the database server issues a database model to the application server;
具体的,数据库服务器可以直接向应用服务器发布数据库模型,也可以向应用服务器发布数据库模型的标识。Specifically, the database server may directly issue a database model to the application server, or may issue an identifier of the database model to the application server.
其中,数据库模型的标识包括但不限于数据库模型的名称。The identifier of the database model includes, but is not limited to, the name of the database model.
第2种实现方式:数据库服务器确定数据库模型的接口配置参数,向应用服务器发布接口配置参数;The second implementation manner: the database server determines the interface configuration parameter of the database model, and publishes the interface configuration parameter to the application server;
数据库服务器定义数据库模型的接口配置参数,约定应用服务器生成的数据查询脚本可以通过该接口配置参数与数据库模型对应的数据库连接,从而实现数据查询脚本对数据库的访问。The database server defines the interface configuration parameters of the database model, and the data query script generated by the application server can be configured to access the database through the interface configuration parameter and the database model corresponding to the database model.
其中,接口配置参数可以为一个公共变量。The interface configuration parameter can be a public variable.
另外,数据库服务器定义的接口配置参数,随着具体实施情况的不同有所变化。例如:In addition, the interface configuration parameters defined by the database server vary with the implementation. E.g:
若数据库访问操作包含基本的创建,删除,更新,插入和查询,这些操作由mongoDB本来的操作指令定义,在应用服务器编程时,可以像编写本地程序一样编写这些预制脚本,达到在数据库服务器上允许数据库分析和运算的效果。因此,数据库服务器必须为该脚本定义以下几个接口的接口配置参数:If the database access operation contains basic creation, deletion, update, insertion and query, these operations are defined by the original operation instructions of mongoDB. When the application server is programmed, these pre-made scripts can be written like the local program to achieve the permission on the database server. The effect of database analysis and calculations. Therefore, the database server must define interface configuration parameters for the following interfaces for the script:
1)数据库连接接口,包含数据库内文档的创建,删除,插入,更新和查询功能,提供一个数据模型的访问接口;1) Database connection interface, including the creation, deletion, insertion, update and query functions of documents in the database, providing an access interface of the data model;
2)基本的javascript基础库接口,提供对数据进行运算和筛选等基本数据分析的于运行环境。2) The basic javascript base library interface provides the runtime environment for basic data analysis such as calculation and filtering of data.
3)提供用于返回的接口,通过调用返回接口的回调函数,退出脚本并返回处理获得的数据。3) Provide an interface for returning, exit the script and return the processed data by calling the callback function of the return interface.
第3种实现方式:数据库服务器向应用服务器发布数据库模型,并且,数据库服务器确定数据库模型的接口配置参数,向应用服务器发布接口配置参数。The third implementation manner: the database server issues a database model to the application server, and the database server determines interface configuration parameters of the database model, and issues interface configuration parameters to the application server.
505:应用服务器获取来自数据存储系统的数据库模型和/或接口配置参数;505: The application server acquires a database model and/or an interface configuration parameter from the data storage system.
应用服务器获取到数据库模型和/或接口配置参数后,可以通过数据库模型和/或接口配置参数与数据库模型对应的数据库进行连接,并基于该连接对该数据库进行访问和操作。After the application server obtains the database model and/or interface configuration parameters, the database model and/or interface configuration parameters may be connected to the database corresponding to the database model, and the database is accessed and operated based on the connection.
例如:应用服务器凭借数据库模型标识获得对应的数据库连接,并对这一数据库表 进行读写。For example, the application server obtains the corresponding database connection by using the database model identifier, and the database table is Read and write.
通过本步骤,可以通过不同的数据库模型和/或接口配置参数与相应数据库模型对应的数据库进行连接,并基于该连接对相应的数据库进行访问和操作,实现数据库的单独控制,以及数据库操作的单独控制,提高并发效率。Through this step, different database models and/or interface configuration parameters can be connected to the database corresponding to the corresponding database model, and the corresponding database can be accessed and operated based on the connection, thereby implementing separate control of the database and separate operation of the database. Control to improve concurrency efficiency.
执行至此,应用服务器与数据库服务器之间建立了数据库连接,基于该连接,应用服务器可以访问相应的数据库,对数据库中的数据进行操作。At this point, a database connection is established between the application server and the database server. Based on the connection, the application server can access the corresponding database and operate on the data in the database.
506:终端发起查询请求后,应用服务器获取数据查询请求,根据数据查询请求生成数据查询脚本;506: After the terminal initiates the query request, the application server obtains the data query request, and generates a data query script according to the data query request.
具体的,应用服务器根据步骤505中获取的来自数据存储系统的数据库模型和/或接口配置参数生成数据查询脚本。Specifically, the application server generates a data query script according to the database model and/or interface configuration parameters from the data storage system acquired in
其中,数据查询脚本中包括但不限于:数据查询语句和结果分析语句。结果分析语句包括但不限于:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。The data query script includes but is not limited to: a data query statement and a result analysis statement. The result analysis statement includes but is not limited to: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
例如,应用服务器根据步骤505中获取的来自数据存储系统的数据库模型和/或接口配置参数生成数据查询脚本,形成如下数据查询脚本:For example, the application server generates a data query script according to the database model and/or interface configuration parameters from the data storage system acquired in
1)查询与终端对话的所有联系人;1) Query all contacts who talk to the terminal;
2)查找与每个联系人对话的最后一条消息;2) Find the last message in conversation with each contact;
3)按时间顺序对每个联系人对话的最后一条消息进行排序,确定最后与终端对话的联系人;3) Sorting the last message of each contact conversation in chronological order, and determining the last contact with the terminal;
4)查询最后与终端对话的联系人的信息。4) Query the information of the last contact with the terminal.
其中,1)、2)、4)为数据查询语句,3)为结果分析语句。Among them, 1), 2), 4) are data query statements, and 3) are result analysis statements.
需要说明的是,上述脚本仅为示例,在实际应用中脚本内容、脚本形式、脚本所用语言均可以适应性变化,本实施例不对具体脚本内容、形式、使用语言进行限定。It should be noted that the above script is only an example. In actual applications, the script content, the script form, and the language used by the script can be adaptively changed. This embodiment does not limit the specific script content, form, and usage language.
507:应用服务器将数据查询脚本发送至数据库服务器;507: The application server sends the data query script to the database server;
例如:应用服务器使用结构化查询语言将数据查询脚本发送至数据库服务器。For example, the application server sends a data query script to the database server using a structured query language.
508:数据库服务器获取来自应用服务器的数据查询脚本后,执行数据查询脚本,获得数据查询结果,并将数据查询结果反馈至应用服务器;508: After obtaining the data query script from the application server, the database server executes the data query script, obtains the data query result, and feeds back the data query result to the application server;
其中,数据查询脚本中包括但不限于:数据查询语句和结果分析语句。结果分析语句包括但不限于:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。The data query script includes but is not limited to: a data query statement and a result analysis statement. The result analysis statement includes but is not limited to: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
例如,数据库服务器先查询与终端对话的所有联系人;再查找与每个联系人对话的最后一条消息;然后按时间顺序对每个联系人对话的最后一条消息进行排序,确定最后 与终端对话的联系人;最后查询最后与用户对话的联系人的信息。For example, the database server first queries all contacts that talk to the terminal; then finds the last message in conversation with each contact; then sorts the last message of each contact conversation in chronological order, determining the final The contact with the terminal; finally the information of the last contact with the user.
另外,在查询时,若数据库服务器不仅存储数据,还缓存部分数据,则查询数据的过程还可以通过如下方式实现:In addition, in the query, if the database server not only stores data but also caches part of the data, the process of querying the data can also be implemented as follows:
首先判断自身有没有缓存相关数据,如果已经进行过缓存,并且缓存没有过期,则获取缓存的数据,从而节约数据库访问。First, it is judged whether or not there is cache related data. If the cache has been cached and the cache has not expired, the cached data is obtained, thereby saving database access.
例如,当查询与终端对话的所有联系人时,先判断自身有没有缓存与终端对话的所有联系人的相关数据,如果已经进行过缓存,并且缓存没有过期,则获取缓存的数据。For example, when querying all contacts in a conversation with the terminal, it is first determined whether or not there is relevant data for all contacts that are in a conversation with the terminal. If the cache has been cached and the cache has not expired, the cached data is obtained.
在具体执行数据查询脚本时,数据库服务器可以支持语言或库类的动态加载,在javascript中,支持使用eval动态加载数据查询脚本,而java则也支持class loader方式的加载数据查询脚本,但是需要进行预编译。In the specific execution of the data query script, the database server can support dynamic loading of language or library classes. In javascript, it supports the use of eval to dynamically load data query scripts, while java also supports loader query scripts in class loader mode, but needs to be performed. Precompiled.
不同语言和框架的数据库服务器动态加载的方式不同,本实施例中使用的Node服务器,本身带有加载动态模块的机制。在输入中,应用服务器仅需要将数据查询脚本编写为一个文本文件发送给数据库服务器,数据库服务器接收后作为模块加载执行。The database server of different languages and frameworks is dynamically loaded. The Node server used in this embodiment has a mechanism for loading dynamic modules. In the input, the application server only needs to write the data query script as a text file and send it to the database server. After the database server receives it, it is loaded as a module.
另外,为了保证数据查询脚本的安全性,数据库服务器脚本加载之前必须校验权限,防止危险代码注入。In addition, in order to ensure the security of the data query script, the database server script must be verified before the script is loaded to prevent dangerous code injection.
509:应用服务器接收数据库服务器执行数据查询脚本得到的结果。509: The application server receives the result obtained by the database server executing the data query script.
通过执行上述9个步骤,不仅把数据运行功能放在数据库服务器上,而把数据分析代码的提供方仍然放在数据库服务器上。同时,数据库服务器执行的是数据查询脚本,而非一般的查询语言,从而优化数据访问的流程,减少频繁的与数据库服务器进行网络通信。通过该种方式,能够在数据库服务器运行时同时执行数据分析和筛选运算并灵活地给出运算结果。By performing the above nine steps, not only the data running function is placed on the database server, but the provider of the data analysis code is still placed on the database server. At the same time, the database server executes the data query script instead of the general query language, thereby optimizing the data access process and reducing the frequent network communication with the database server. In this way, data analysis and filtering operations can be performed simultaneously while the database server is running and the operation results can be flexibly given.
为了更加简单明了的说明本实施例提供的数据查询方法,参见图6,该方法整体流程为:1)应用服务器应用部署;2)应用服务器应用初始化;3)应用服务器定义数据模型;4)应用服务器确认数据库服务器中是否存在数据模型,若不存在,则执行5),若存在,则执行6);5)应用服务器向数据库服务器方发送数据模型;6)应用服务器从数据库服务器获取配置,该配置包括但不限于数据库模型和/或接口配置参数;7)应用服务器向数据库服务器发送数据查询脚本;8)应用服务器确定查询是否结束,若结束,则执行9),若未结束,则执行7);9)应用服务器输出结果。For a more detailed explanation of the data query method provided by this embodiment, referring to FIG. 6, the overall process of the method is: 1) application server application deployment; 2) application server application initialization; 3) application server definition data model; 4) application The server confirms whether there is a data model in the database server, if it does not exist, executes 5), if it exists, executes 6); 5) the application server sends the data model to the database server side; 6) the application server acquires the configuration from the database server, The configuration includes, but is not limited to, a database model and/or interface configuration parameters; 7) the application server sends a data query script to the database server; 8) the application server determines whether the query is finished, if it is finished, executes 9), and if not, executes 7 ); 9) Application server output results.
上述方法将部分数据分析和处理操作直接放到数据库服务器上执行,解决数据库服务器中数据库访问查询不方便的问题,扩展数据库操作的执行方式。 The above method directly puts part of the data analysis and processing operations on the database server, solves the problem that the database access query in the database server is inconvenient, and expands the execution mode of the database operation.
进一步地,为了更加明显的说明本实施例提供的数据查询方法的优势,现将现有数据查询方法的实现流程与本实施例提供的数据查询方法的实现流程进行对照。Further, in order to more clearly illustrate the advantages of the data query method provided by this embodiment, the implementation flow of the existing data query method is compared with the implementation flow of the data query method provided by this embodiment.
参见图7,现有数据查询方法的实现流程如下:1)终端向应用服务器发送查询请求;2)应用服务器处理该查询请求;3)应用服务器根据该查询请求向数据库服务器发送数据请求;4)数据库服务器解析数据请求,确定查询内容;5)数据库服务器基于存储器执行查询;6)存储器进行数据库访问获得查询数据;7)存储器向数据库服务器返回数据;8)数据库服务器向应用服务器返回数据;9)应用服务器分析返回的数据;10)应用服务器根据分析结果再次向数据库服务器发送数据请求;11)数据库服务器解析数据请求,确定查询内容;12)数据库服务器基于存储器执行查询;13)存储器进行数据库访问获得查询数据;14)存储器向数据库服务器返回数据;15)数据库服务器向应用服务器返回数据;16)应用服务器分析返回的数据,得到最终结果;17)应用服务器向终端返回最终结果。Referring to FIG. 7, the implementation process of the existing data query method is as follows: 1) the terminal sends a query request to the application server; 2) the application server processes the query request; 3) the application server sends a data request to the database server according to the query request; 4) The database server parses the data request, determines the query content; 5) the database server performs the query based on the memory; 6) the memory performs the database access to obtain the query data; 7) the memory returns the data to the database server; 8) the database server returns the data to the application server; 9) The application server analyzes the returned data; 10) the application server sends the data request to the database server again according to the analysis result; 11) the database server parses the data request, determines the query content; 12) the database server performs the query based on the memory; 13) the memory performs the database access Query data; 14) the memory returns data to the database server; 15) the database server returns data to the application server; 16) the application server analyzes the returned data to obtain the final result; 17) the application server returns the final result to the terminal.
参见图8,本实施例提供的数据查询方法的实现流程如下:1)终端向应用服务器发送业务请求;2)应用服务器处理该业务请求;3)应用服务器构建数据查询脚本;4)应用服务器向数据库服务器发送数据查询脚本;5)数据库服务器加载数据查询脚本;6)数据库服务器执行数据查询脚本;7)存储器进行数据库访问获得查询数据;8)存储器向数据库服务器返回数据;9)数据库服务器根据存储器返回的数据进行数据分析;10)数据库服务器基于存储器再次执行查询;11)存储器进行数据库访问获得查询数据;12)存储器向数据库服务器返回数据;13)数据库服务器向应用服务器返回数据;14)应用服务器分析返回的数据,得到最终结果;15)应用服务器向终端返回最终结果。Referring to FIG. 8, the implementation process of the data query method provided by this embodiment is as follows: 1) the terminal sends a service request to the application server; 2) the application server processes the service request; 3) the application server constructs the data query script; 4) the application server The database server sends the data query script; 5) the database server loads the data query script; 6) the database server executes the data query script; 7) the memory performs the database access to obtain the query data; 8) the memory returns the data to the database server; 9) the database server according to the memory The returned data is analyzed for data; 10) the database server executes the query again based on the memory; 11) the memory performs database access to obtain the query data; 12) the memory returns data to the database server; 13) the database server returns data to the application server; 14) the application server Analyze the returned data to get the final result; 15) The application server returns the final result to the terminal.
对数据之间关系的定义往往依赖于数据库本身实现。例如:mongoDB中的find语句,以及一些and或者or的操作符,这些操作符仅能进行简单的运算,不能够支持复杂数据筛选或者运算等操作。The definition of the relationship between data often depends on the implementation of the database itself. For example: the find statement in mongoDB, and some operators of and or or, these operators can only perform simple operations, and can not support complex data filtering or operations.
因为以上原因,对于复杂数据筛选,现有的实现流程,仅能放在应用服务器实现,通过查询数据库获得一个粗略的结果,再返回到应用服务器程序中运行筛选或者分析处理,最后再根据运行结果执行下一步查询操作。For the above reasons, for complex data filtering, the existing implementation process can only be implemented in the application server, obtain a rough result by querying the database, and then return to the application server program to run the screening or analysis processing, and finally according to the running result. Perform the next query operation.
本实施例提出的数据查询方法,直接将数据查询脚本作为查询请求的一部分发送到数据服务器,数据库服务器执行数据查询脚本从数据库内查询并运算出最终数据返回应用服务器。使得在应用服务器方面,开发人员只需要实现准备数据查询脚本,并在查询 发生时动态去修改这些数据查询脚本,通过数据库查询端口发送到数据库服务器。数据库服务器直接返回数据查询脚本执行的结果,从而避免频繁网络访问问题,对于异地分布的系统来说,节约大量网络通信延迟时间,并缓解本地应用服务器在处理网络返回的查询结果时的运算压力。The data query method proposed in this embodiment directly sends the data query script as part of the query request to the data server, and the database server executes the data query script to query from the database and calculate the final data to be returned to the application server. In terms of the application server, the developer only needs to implement the preparation data query script and query Dynamically modify these data query scripts when they occur, and send them to the database server through the database query port. The database server directly returns the results of the data query script execution, thereby avoiding frequent network access problems. For a system distributed remotely, it saves a lot of network communication delay time and alleviates the computing pressure of the local application server in processing the query results returned by the network.
在数据分析密集型的应用中,使用这一方案,可以显著减少网络请求次数,从而节约应用服务器与数据库服务器的通信时间。显著缩短了应用服务器访问数据库服务器所花费的时间。而动态构建数据查询脚本也增加了数据库服务器使用灵活性。In data analysis-intensive applications, using this solution can significantly reduce the number of network requests, thereby saving communication time between the application server and the database server. Significantly reduces the time it takes for the application server to access the database server. Dynamically building data query scripts also increases the flexibility of database server usage.
有益效果:Beneficial effects:
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
当数据查询并发情况增多时,可以利用数据存储系统本身的并发能力,提升数据查询效率。When the data query concurrent situation increases, the data storage system's own concurrency capability can be utilized to improve data query efficiency.
其中,本实施例不对数据存储系统并发能力的具体实现方式进行限定,例如:数据存储系统由中间件和数据库服务器组成,由中间件对数据查询脚本进行分发,实现数据存储系统的并发运行。The embodiment does not limit the specific implementation manner of the data storage system concurrency. For example, the data storage system is composed of middleware and a database server, and the data query script is distributed by the middleware to implement concurrent execution of the data storage system.
中间件对数据查询脚本进行分发时,由于在数据密集型应用中读数据库的频率以及硬盘访问远大于写数据库,通过中间件对数据查询脚本的拆分,优化数据查询顺序,进而优化数据库访问过程,减少对数据库读取的次数和读取范围,优化运行效率。对分布在不同数据库服务器上的数据库进行查询时,通过数据查询脚本的拆分,可以充分利用不同数据库服务器的CPU进行运算,统一返回运行结果,该种方式的实现流程可以参见图9所示的实施例。When the middleware distributes the data query script, because the frequency of reading the database and the hard disk access in the data-intensive application is much larger than the write database, the data query script is split by the middleware to optimize the data query sequence, thereby optimizing the database access process. , reduce the number of readings and reading range of the database, optimize the operation efficiency. When querying the database distributed on different database servers, through the splitting of the data query script, you can make full use of the CPU of different database servers to perform operations and return the running results uniformly. The implementation process of this method can be seen in Figure 9. Example.
图9所示的实施例以如下具体场景为例,对于其他场景,可参见如下场景的实现方式。The embodiment shown in FIG. 9 is exemplified by the following specific scenarios. For other scenarios, refer to the implementation of the following scenarios.
具体场景:在一个聊天应用中,用户通过结构化查询语言查询最后与自己对话的联系人信息,数据存储系统由中间件和一台或多台数据库服务器组成。Specific scenario: In a chat application, the user queries the contact information that is finally in conversation with himself through the structured query language. The data storage system consists of middleware and one or more database servers.
参见图9,该方法流程具体如下: Referring to Figure 9, the process of the method is as follows:
901:应用服务器获取待存储数据的数据模型;901: The application server acquires a data model of data to be stored.
本步骤的实现方式与步骤501相同,可参见步骤501,此处不再赘述。The implementation of this step is the same as that of
902:应用服务器将数据模型发送至数据库服务器;902: The application server sends the data model to the database server.
本步骤的实现方式与步骤502相同,可参见步骤502,此处不再赘述。The implementation of this step is the same as that of
903:数据库服务器接收应用服务器发送的数据模型,根据数据模型定义数据库模型;903: The database server receives the data model sent by the application server, and defines a database model according to the data model.
数据库服务器可以直接接收应用服务器发送的数据模型,也可以通过中间件接收应用服务器发送的数据模型。The database server can directly receive the data model sent by the application server, or receive the data model sent by the application server through the middleware.
通过执行步骤901至步骤903,数据库服务器会建立与待存储数据匹配的数据库,该数据库的数据库模型与待存储数据的数据模型相同。By performing
步骤901至步骤903,除在初次执行本实施例提供的数据查询方法时执行外,还可以在其他情况下执行。例如:当应用服务器监测到待存储数据的数据模型发生改变时,触发执行步骤901至步骤903。再例如:数据库服务器监测到数据库模型与待存储数据的数据模型不匹配时,触发执行步骤901至步骤903。本实施例不对执行步骤901至步骤903的具体触发条件进行限定。
904:数据库服务器建立数据库模型与应用服务器之间的关联关系;904: The database server establishes an association relationship between the database model and the application server.
此步骤的具体实现方式,包括但不限于如下3种。Specific implementations of this step include, but are not limited to, the following three types.
第1种实现方式:数据库服务器向应用服务器发布数据库模型;The first implementation manner: the database server issues a database model to the application server;
第2种实现方式:数据库服务器确定数据库模型的接口配置参数,向应用服务器发布接口配置参数;The second implementation manner: the database server determines the interface configuration parameter of the database model, and publishes the interface configuration parameter to the application server;
第3种实现方式:数据库服务器向应用服务器发布数据库模型,并且,数据库服务器确定数据库模型的接口配置参数,向应用服务器发布接口配置参数。The third implementation manner: the database server issues a database model to the application server, and the database server determines interface configuration parameters of the database model, and issues interface configuration parameters to the application server.
其中,数据库服务器可以直接向应用服务器发布数据库模型,也可以通过中间件向应用服务器发布数据库模型。数据库服务器可以直接向应用服务器发布接口配置参数,也可以通过中间件向应用服务器发布接口配置参数。The database server may directly publish the database model to the application server, or may publish the database model to the application server through the middleware. The database server can directly publish interface configuration parameters to the application server, and can also publish interface configuration parameters to the application server through the middleware.
905:应用服务器获取来自数据存储系统的数据库模型和/或接口配置参数;905: The application server acquires a database model and/or an interface configuration parameter from the data storage system.
应用服务器可以直接获取来自数据存储系统的数据库模型和/或接口配置参数,也可以通过中间件获取来自数据存储系统的数据库模型和/或接口配置参数。The application server can directly obtain the database model and/or interface configuration parameters from the data storage system, and can also obtain the database model and/or interface configuration parameters from the data storage system through the middleware.
906:终端发起查询请求后,应用服务器获取数据查询请求,根据数据查询请求生成数据查询脚本;906: After the terminal initiates the query request, the application server obtains a data query request, and generates a data query script according to the data query request.
本步骤的实现方式与步骤506相同,可参见步骤506,此处不再赘述。
The implementation of this step is the same as that of
907:应用服务器将数据查询脚本发送至中间件;907: The application server sends the data query script to the middleware;
908:中间件获取来自应用服务器的数据查询脚本,确定执行数据查询脚本的一个或多个数据库服务器后,将数据查询脚本分发至数据库服务器;908: The middleware acquires a data query script from the application server, and after determining one or more database servers that execute the data query script, distributes the data query script to the database server;
具体的,中间件可以获取各个数据库服务器存储的数据情况,选择执行数据查询脚本的数据库服务器,向每一个选择的数据库服务器分发一份数据查询脚本。Specifically, the middleware can obtain the data stored by each database server, select a database server that executes the data query script, and distribute a data query script to each selected database server.
例如,数据查询脚本为:查询与用户语音对话的所有语音联系人以及与用户短信对话的所有短信联系人。For example, the data query script is: query all voice contacts that talk to the user's voice and all text messages that are in conversation with the user's text message.
若存储语音通话数据的数据库服务器有2个,数据库服务器11和数据库服务器12,其中,数据库服务器11存储有用户0-100号的语音联系人,数据库服务器12存储有用户100-200号的语音联系人。存储语音通话数据的数据库服务器有2个,数据库服务器21和数据库服务器22,其中,数据库服务器21存储有用户0-100号的短信联系人,数据库服务器22存储有用户100-200号的短信联系人。If there are two database servers storing voice call data, the database server 11 and the database server 12, wherein the database server 11 stores the voice contacts of the user 0-100, and the database server 12 stores the voice contacts of the user 100-200. people. There are two database servers for storing voice call data, a database server 21 and a database server 22, wherein the database server 21 stores the short message contacts of the user 0-100, and the database server 22 stores the short message contacts of the user 100-200. .
此步骤将数据查询脚本分发给数据库服务器11、数据库服务器12、数据库服务器21和数据库服务器22。即向数据库服务器11发送一份数据查询脚本、向数据库服务器12发送一份数据查询脚本、向数据库服务器21发送一份数据查询脚本、向数据库服务器22发送一份数据查询脚本。This step distributes the data query script to the database server 11, database server 12, database server 21, and database server 22. That is, a data query script is sent to the database server 11, a data query script is sent to the database server 12, a data query script is sent to the database server 21, and a data query script is sent to the database server 22.
909:数据库服务器获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本后,执行分发的数据查询脚本,获得数据查询结果,并将数据查询结果反馈至中间件;909: The database server obtains the data query script distributed by the middleware based on the data query script from the application server, executes the distributed data query script, obtains the data query result, and feeds back the data query result to the middleware;
数据库服务器可以根据其存储的数据确定出数据查询脚本中哪些部分是该数据库服务器可以执行的,哪些部分不需要执行。数据库服务器获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本后,执行分发的数据查询脚本中其认为需要执行的部分。The database server can determine which parts of the data query script are executable by the database server based on the data it stores, and which parts do not need to be executed. After the database server obtains the data query script distributed by the middleware based on the data query script from the application server, it executes the part of the distributed data query script that it thinks needs to be executed.
以数据查询脚本为:查询与用户语音对话以及与用户短信对话的所有联系人为例。The data query script is as follows: Query the voice conversation with the user and all the contacts who talk to the user SMS.
数据库服务器11,其存储有用户0-100号的语音联系人,因此,其可以执行查询与用户语音对话的0-100号语音联系人。数据库服务器11仅执行在0-100号语音联系人中,查询与用户语音对话的语言联系人部分,不执行在101-200号语音联系人中,查询与用户语音对话的语音联系人部分以及查询与用户短信对话的所有短信联系人部分。获得针对0-100号语音联系人的数据查询结果后,将数据查询结果反馈至中间件。The database server 11, which stores the voice contacts of the user number 0-100, can therefore perform a voice contact number 0-100 that queries the user's voice conversation. The database server 11 executes only in the voice contact number 0-100, queries the language contact part of the conversation with the user voice, does not execute in the voice contact number 101-200, queries the voice contact part of the conversation with the user voice and the query All SMS contact sections that are in conversation with the user's text message. After obtaining the data query result for the voice contact number 0-100, the data query result is fed back to the middleware.
数据库服务器12,其存储有用户101-200号的语音联系人,因此,其可以执行查询 与用户语音对话的101-200号语音联系人。数据库服务器12仅执行在101-200号语音联系人中,查询与用户语音对话的语言联系人部分,不执行在0-100号语音联系人中,查询与用户语音对话的语音联系人部分以及查询与用户短信对话的所有短信联系人部分。获得针对101-200号语音联系人的数据查询结果后,将数据查询结果反馈至中间件。The database server 12 stores the voice contacts of the user number 101-200, so that it can execute the query Voice contact number 101-200 in conversation with the user voice. The database server 12 executes only in the voice contact number 101-200, queries the language contact part of the conversation with the user voice, does not execute in the voice contact number 0-100, queries the voice contact part of the conversation with the user voice and the query All SMS contact sections that are in conversation with the user's text message. After obtaining the data query result for the voice contact number 101-200, the data query result is fed back to the middleware.
数据库服务器21,其存储有用户0-100号的短信联系人,因此,其可以执行查询与用户短信对话的0-100号短信联系人。数据库服务器11仅执行在0-100号短信联系人中,查询与用户短信对话的短信联系人部分,不执行在101-200号短信联系人中,查询与用户短信对话的短信联系人部分以及查询与用户语音对话的所有语音联系人部分。获得针对0-100号短信联系人的数据查询结果后,将数据查询结果反馈至中间件。The database server 21 stores the short message contacts of the user 0-100, so that it can execute the SMS-number 0-100 contact that queries the user's short message. The database server 11 executes only the short message contact in the 0-100 number, queries the short message contact part of the short message conversation with the user, does not execute in the short message contact number 101-200, and queries the short message contact part of the short message conversation with the user and the query. All voice contact sections that talk to the user's voice. After obtaining the data query result for the SMS contact number 0-100, the data query result is fed back to the middleware.
数据库服务器22,其存储有用户101-200号的短信联系人,因此,其可以执行查询与用户短信对话的101-200号短信联系人。数据库服务器22仅执行在101-200号短信联系人中,查询与用户短信对话的短信联系人部分,不执行在0-100号短信联系人中,查询与用户短信对话的短信联系人部分以及查询与用户语音对话的所有语音联系人部分。获得针对101-200号短信联系人的数据查询结果后,将数据查询结果反馈至中间件。The database server 22 stores the short message contacts of the user No. 101-200, and therefore, it can execute the short message contacts No. 101-200 for inquiring the short message with the user. The database server 22 only executes the short message contact part in the short message contact number 101-200, and queries the short message contact part of the short message conversation with the user, does not execute the short message contact part in the 0-100 number, and queries the short message contact part of the short message conversation with the user and the query. All voice contact sections that talk to the user's voice. After obtaining the data query result for the short message contact number 101-200, the data query result is fed back to the middleware.
在查询时,若数据库服务器不仅存储数据,还缓存部分数据,则查询数据的过程还可以首先判断自身有没有缓存相关数据,如果已经进行过缓存,并且缓存没有过期,则获取缓存的数据,从而节约数据库访问。During the query, if the database server not only stores data but also caches part of the data, the process of querying the data may first determine whether it has cached related data, and if the cache has been cached, and the cache has not expired, the cached data is obtained, thereby obtaining the cached data. Save database access.
910:中间件获得数据库服务器反馈的数据查询结果,并将数据查询结果发送至应用服务器;910: The middleware obtains the data query result fed back by the database server, and sends the data query result to the application server;
由于数据库服务器执行数据查询脚本中与其相关的部分,因此本步骤中间件在获得各数据库服务器反馈的数据查询结果后,会对各数据查询结果进行汇总,将汇总的结果发送至应用服务器。Since the database server executes the relevant part of the data query script, the middleware of the step obtains the data query result fed back by each database server, summarizes the data query results, and sends the summarized result to the application server.
汇总的具体方式可以为各数据库服务器反馈的数据查询结果的叠加。The specific way of summarizing can be the superposition of the data query results fed back by each database server.
例如:中间件获得数据库服务器11反馈的针对0-100号语音联系人的数据查询结果、数据库服务器12反馈的针对101-200号语音联系人的数据查询结果、数据库服务器21反馈的针对0-100号短信联系人的数据查询结果、数据库服务器22反馈的针对101-200号短信联系人的数据查询结果后,将上述4各结果叠加到一起,得到0-200号语音联系人的数据查询结果以及0-200号短信联系人的数据查询结果,将0-200号语音联系人的数据查询结果以及0-200号短信联系人的数据查询结果发送至应用服务器。For example, the middleware obtains the data query result for the voice contact number 0-100 fed back by the database server 11, the data query result for the voice contact of the number 101-200 fed back by the database server 12, and the feedback from the database server 21 for 0-100. After the data query result of the SMS contact, and the data query result reported by the database server 22 for the SMS contact number 101-200, the above four results are superimposed together to obtain the data query result of the voice contact 0-200 and The data query result of the SMS contact number 0-200 sends the data query result of the voice contact 0-200 and the data query result of the voice contact 0-200 to the application server.
911:应用服务器接收中间件发送的结果。 911: The application server receives the result of the middleware transmission.
为了更加明显的说明本实施例提供的数据查询方法的优势,现将本实施例提供的数据查询方法再次进行说明。参见图10,1)终端向应用服务器发送业务请求;2)应用服务器处理该业务请求;3)应用服务器向中间件发送配置查询请求;4)中间件查询配置,并返回查询的配置,该配置包括但不限于数据库模型和/或接口配置参数;5)应用服务器根据该配置构建数据查询脚本;6)应用服务器向中间件发送数据查询脚本;7)中间件分发数据查询脚本;8)分发到数据查询脚本的数据库服务器基于数据查询脚本执行查询;9)数据库服务器向中间件返回执行结果;10)数据库服务器汇总执行结果后向应用服务器返回汇总的结果;11)应用服务器分析返回的汇总结果,得到最终结果;15)应用服务器向终端返回最终结果。In order to more clearly illustrate the advantages of the data query method provided by this embodiment, the data query method provided in this embodiment will be described again. Referring to FIG. 10, 1) the terminal sends a service request to the application server; 2) the application server processes the service request; 3) the application server sends a configuration query request to the middleware; 4) the middleware query configuration, and returns the query configuration, the configuration Including but not limited to database model and/or interface configuration parameters; 5) application server builds data query script according to the configuration; 6) application server sends data query script to middleware; 7) middleware distributes data query script; 8) distributes to The database server of the data query script executes the query based on the data query script; 9) the database server returns the execution result to the middleware; 10) the database server summarizes the execution result and returns the summarized result to the application server; 11) the application server analyzes the returned summary result, The final result is obtained; 15) the application server returns the final result to the terminal.
通过执行动态数据查询脚本可以更加精确智能地在数据库中查找所需要的结果,在数据库进行拆分后,也可以通过将运算分布在不同数据库减少数据库服务器的负担。By executing the dynamic data query script, the required results can be searched more accurately and intelligently in the database. After the database is split, the burden of the database server can also be reduced by distributing the operations in different databases.
有益效果:Beneficial effects:
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
基于同一发明构思,本实施例提供了一种应用服务器,由于该应用服务器解决问题的原理与图2所示的一种数据查询方法相似,因此该应用服务器的实施可以参见图2所示的方法的实施例,重复之处不再赘述。Based on the same inventive concept, the embodiment provides an application server. The principle of the application server is similar to the data query method shown in FIG. 2, so the implementation of the application server can refer to the method shown in FIG. The embodiments are not repeated here.
参见图11,该应用服务器包括:Referring to Figure 11, the application server includes:
第一获取模块1101,用于获取数据查询请求;The first obtaining
生成模块1102,用于根据第一获取模块1101获取的数据查询请求生成数据查询脚本;a
第一发送模块1103,用于将生成模块1102生成的数据查询脚本发送至数据存储系统;The
接收模块1104,用于接收数据存储系统执行第一发送模块1103发送的数据查询脚本得到的结果。The
可选地,数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以 上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or Any combination of the above.
可选地,生成模块1102,用于获取来自数据存储系统的数据库模型和/或接口配置参数,根据数据库模型和/或接口配置参数生成数据查询脚本。Optionally, the
参见图12,该应用服务器,还包括:Referring to FIG. 12, the application server further includes:
第二获取模块1105,用于获取待存储数据的数据模型;a second obtaining
第二发送模块1106,用于将第二获取模块1105获取的数据模型发送至数据存储系统,以使数据存储系统根据数据模型定义数据库模型。The
有益效果如下:The benefits are as follows:
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
基于同一发明构思,本实施例提供了一种数据库服务器,由于该数据库服务器解决问题的原理与图3所示的一种数据查询方法相似,因此该数据库服务器的实施可以参见图3所示的方法的实施例,重复之处不再赘述。Based on the same inventive concept, the embodiment provides a database server. The principle of solving the problem is similar to the data query method shown in FIG. 3, so the implementation of the database server can be referred to the method shown in FIG. The embodiments are not repeated here.
参见图13,该数据库服务器包括:Referring to Figure 13, the database server includes:
获取模块1301,用于获取来自应用服务器的数据查询脚本;An obtaining
执行模块1302,用于执行获取模块1301获取的数据查询脚本,获得数据查询结果;The
反馈模块1303,用于将执行模块1302获得的数据查询结果反馈至应用服务器。The
可选地,数据查询脚本中包括数据查询语句和结果分析语句。Optionally, the data query script includes a data query statement and a result analysis statement.
可选地,结果分析语句包括:结果筛选语句、结果排序语句或结果运算语句,或以上的任意组合。Optionally, the result analysis statement includes: a result screening statement, a result sorting statement, or a result operation statement, or any combination of the above.
可选地,获取模块1301,用于获取中间件基于来自应用服务器的数据查询脚本分发的数据查询脚本;Optionally, the obtaining
反馈模块1303,用于通过中间件将数据查询结果反馈至应用服务器。The
参见图14,该数据库服务器,还包括:Referring to Figure 14, the database server further includes:
接收模块1304,用于接收应用服务器发送的数据模型;The
定义模块1305,用于根据接收模块1304接收的数据模型定义数据库模型;a
建立模块1306,用于建立定义模块1305定义的数据库模型与应用服务器之间的关
联关系。The
可选地,建立模块1306,用于向应用服务器发布数据库模型,和/或,确定数据库模型的接口配置参数,向应用服务器发布接口配置参数。Optionally, the
有益效果如下:The benefits are as follows:
获取到应用服务器根据数据查询请求生成数据查询脚本后,执行该数据查询脚本,将执行脚本得到的结果反馈至应用服务器,使得仅接收应用服务器发送一次数据查询脚本,即可根据数据查询脚本获取最终结果,降低了与应用服务器之间的访问次数,提高数据查询效率。After the application server generates the data query script according to the data query request, the data query script is executed, and the result obtained by the execution script is fed back to the application server, so that only the receiving application server sends the data query script, and the final result can be obtained according to the data query script. As a result, the number of accesses with the application server is reduced, and data query efficiency is improved.
基于同一发明构思,本实施例提供了一种中间件,由于该中间件解决问题的原理与图4所示的一种数据查询方法相似,因此该中间件的实施可以参见图4所示的方法的实施例,重复之处不再赘述。Based on the same inventive concept, the present embodiment provides a middleware. Since the principle of solving the problem is similar to the data query method shown in FIG. 4, the implementation of the middleware can be referred to the method shown in FIG. The embodiments are not repeated here.
参见图15,该中间件包括:Referring to Figure 15, the middleware includes:
第一获取模块1501,用于获取来自应用服务器的数据查询脚本;a first obtaining
确定模块1502,用于确定执行第一获取模块1501获取的数据查询脚本的一个或多个数据库服务器;a determining
发送模块1503,用于将第一获取模块1502获取的数据查询脚本分发至数据库服务器;The sending
第二获取模块1504,用于获得数据库服务器反馈的数据查询结果;a second obtaining
发送模块1505,用于将第二获取模块1504获取的数据查询结果发送至应用服务器。The sending
有益效果如下:The benefits are as follows:
中间件获取到应用服务器根据数据查询请求生成数据查询脚本后,将数据查询脚本分发至数据库服务器,使数据库服务器执行分发的数据查询脚本,将数据库服务器返回的数据查询结果发送至应用服务器,使得仅需接收应用服务器发送一次数据查询脚本,即可根据数据查询脚本获取数据、分析数据得到结果,降低了与应用服务器之间的访问次数,提高数据查询效率。After the middleware obtains the data query script generated by the application server according to the data query request, the data query script is distributed to the database server, so that the database server executes the distributed data query script, and the data query result returned by the database server is sent to the application server, so that only The application server needs to send a data query script to obtain data according to the data query script and analyze the data to obtain the result, thereby reducing the number of accesses with the application server and improving the data query efficiency.
基于同一发明构思,本实施例提供了一种数据查询系统,该系统用于执行图5或图6所述实施例所提供的数据查询方法,参见图16,该系统包括:应用服务器1601和数据存储系统1602;
Based on the same inventive concept, the present embodiment provides a data query system for performing the data query method provided by the embodiment shown in FIG. 5 or FIG. 6. Referring to FIG. 16, the system includes: an
其中,应用服务器1601如图11或图12所示的应用服务器;The
数据存储系统1602由如图13或图14所示的数据库服务器,或者,数据存储系统1602由如图13或图14所示的数据库服务器和如图15所示的中间件组成。The
有益效果如下:The benefits are as follows:
获取数据查询请求,根据数据查询请求生成数据查询脚本;将数据查询脚本发送至数据存储系统;接收数据存储系统执行数据查询脚本得到的结果,使得仅向数据存储系统发送一次数据查询脚本,数据存储系统即可根据数据查询脚本获取最终结果,降低了与数据存储系统之间的访问次数,提高数据查询效率。Obtaining a data query request, generating a data query script according to the data query request; sending the data query script to the data storage system; receiving the result obtained by the data storage system executing the data query script, so that only the data query script is sent to the data storage system, and the data storage is performed. The system can obtain the final result according to the data query script, reduce the number of accesses with the data storage system, and improve the efficiency of data query.
为了描述的方便,以上所述装置的各部分以功能分为各种模块或单元分别描述。当然,在实施本发明时可以把各模块或单元的功能在同一个或多个软件或硬件中实现。For convenience of description, the various parts of the above described devices are described in terms of functions divided into various modules or units. Of course, the functions of the various modules or units may be implemented in one or more software or hardware in the practice of the invention.
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art will appreciate that embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。The present invention has been described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (system), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or FIG. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing device to produce a machine for the execution of instructions for execution by a processor of a computer or other programmable data processing device. Means for implementing the functions specified in one or more of the flow or in a block or blocks of the flow chart.
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。The computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device. The apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图 一个方框或多个方框中指定的功能的步骤。These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device. The instructions are provided for implementing one or more processes and/or block diagrams in the flowchart The steps of a function specified in a box or multiple boxes.
尽管已描述了本发明的优选实施例,但本领域内的技术人员一旦得知了基本创造性概念,则可对这些实施例作出另外的变更和修改。所以,所附权利要求意欲解释为包括优选实施例以及落入本发明范围的所有变更和修改。 While the preferred embodiment of the invention has been described, it will be understood that Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and the modifications and
Claims (25)
Priority Applications (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2016/096670 WO2018035799A1 (en) | 2016-08-25 | 2016-08-25 | Data query method, application and database servers, middleware, and system |
| CN201680088647.1A CN109643305A (en) | 2016-08-25 | 2016-08-25 | Data query method, application and database server, middleware and system |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| PCT/CN2016/096670 WO2018035799A1 (en) | 2016-08-25 | 2016-08-25 | Data query method, application and database servers, middleware, and system |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2018035799A1 true WO2018035799A1 (en) | 2018-03-01 |
Family
ID=61245966
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2016/096670 Ceased WO2018035799A1 (en) | 2016-08-25 | 2016-08-25 | Data query method, application and database servers, middleware, and system |
Country Status (2)
| Country | Link |
|---|---|
| CN (1) | CN109643305A (en) |
| WO (1) | WO2018035799A1 (en) |
Cited By (8)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110362613A (en) * | 2019-07-22 | 2019-10-22 | 中国联合网络通信集团有限公司 | Data processing method and equipment |
| CN111143416A (en) * | 2019-12-25 | 2020-05-12 | 深圳广联赛讯有限公司 | Data cache-based query method, terminal and storage medium |
| CN111324545A (en) * | 2020-03-13 | 2020-06-23 | 中国工商银行股份有限公司 | Application server middleware performance test method, test terminal, application server |
| CN111522642A (en) * | 2020-04-21 | 2020-08-11 | 观为监测技术无锡股份有限公司 | Method for acquiring state monitoring data of wind turbine generator, query method and electronic equipment |
| CN113312374A (en) * | 2021-05-18 | 2021-08-27 | 网银在线(北京)科技有限公司 | Data query method, device, equipment and storage medium |
| CN114974605A (en) * | 2022-05-24 | 2022-08-30 | 山东浪潮智慧医疗科技有限公司 | Method for inquiring multiple nucleic acid reports in high-concurrency scene |
| CN117149802A (en) * | 2023-06-29 | 2023-12-01 | 南京维拓科技股份有限公司 | Statistical analysis method of industrial cloud application usage |
| CN117290411A (en) * | 2023-11-22 | 2023-12-26 | 深圳九有数据库有限公司 | Multimode database query method and device, electronic equipment and storage medium |
Families Citing this family (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110874214B (en) * | 2019-11-14 | 2023-06-16 | 北京明略软件系统有限公司 | Function calling method and device, electronic equipment and storage medium |
| CN111104421A (en) * | 2019-12-31 | 2020-05-05 | 新奥数能科技有限公司 | Data query method and device based on data interface standard configuration |
Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101488026A (en) * | 2009-02-26 | 2009-07-22 | 福州欣创摩尔电子科技有限公司 | Distributed data acquisition control platform system |
| CN103856969A (en) * | 2014-03-28 | 2014-06-11 | 大唐移动通信设备有限公司 | Method, device and system for counting network element characteristic parameters |
| CN103853743A (en) * | 2012-11-29 | 2014-06-11 | 百度在线网络技术(北京)有限公司 | Distributed system and log query method thereof |
| CN104050161A (en) * | 2013-03-11 | 2014-09-17 | Sap股份公司 | Dynamic bridging of application and data servers |
| CN105786932A (en) * | 2014-12-26 | 2016-07-20 | 北大医疗信息技术有限公司 | Query method and query apparatus for clinical business in medical system |
Family Cites Families (3)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN1588369A (en) * | 2004-09-06 | 2005-03-02 | 杭州恒生电子股份有限公司 | Relation type data base system and its search and report method |
| JP2013025446A (en) * | 2011-07-19 | 2013-02-04 | Canon Marketing Japan Inc | Information processing apparatus, information processing system, information processing method, program and recording medium |
| CN104346378B (en) * | 2013-07-31 | 2019-02-05 | 腾讯科技(深圳)有限公司 | A kind of method, apparatus and system for realizing complex data processing |
-
2016
- 2016-08-25 WO PCT/CN2016/096670 patent/WO2018035799A1/en not_active Ceased
- 2016-08-25 CN CN201680088647.1A patent/CN109643305A/en active Pending
Patent Citations (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN101488026A (en) * | 2009-02-26 | 2009-07-22 | 福州欣创摩尔电子科技有限公司 | Distributed data acquisition control platform system |
| CN103853743A (en) * | 2012-11-29 | 2014-06-11 | 百度在线网络技术(北京)有限公司 | Distributed system and log query method thereof |
| CN104050161A (en) * | 2013-03-11 | 2014-09-17 | Sap股份公司 | Dynamic bridging of application and data servers |
| CN103856969A (en) * | 2014-03-28 | 2014-06-11 | 大唐移动通信设备有限公司 | Method, device and system for counting network element characteristic parameters |
| CN105786932A (en) * | 2014-12-26 | 2016-07-20 | 北大医疗信息技术有限公司 | Query method and query apparatus for clinical business in medical system |
Cited By (12)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN110362613A (en) * | 2019-07-22 | 2019-10-22 | 中国联合网络通信集团有限公司 | Data processing method and equipment |
| CN111143416A (en) * | 2019-12-25 | 2020-05-12 | 深圳广联赛讯有限公司 | Data cache-based query method, terminal and storage medium |
| CN111143416B (en) * | 2019-12-25 | 2024-01-30 | 深圳广联赛讯股份有限公司 | Query method, terminal and storage medium based on data cache |
| CN111324545A (en) * | 2020-03-13 | 2020-06-23 | 中国工商银行股份有限公司 | Application server middleware performance test method, test terminal, application server |
| CN111324545B (en) * | 2020-03-13 | 2023-09-22 | 中国工商银行股份有限公司 | Application server middleware performance test method, test terminal and application server |
| CN111522642A (en) * | 2020-04-21 | 2020-08-11 | 观为监测技术无锡股份有限公司 | Method for acquiring state monitoring data of wind turbine generator, query method and electronic equipment |
| CN111522642B (en) * | 2020-04-21 | 2024-02-13 | 观为监测技术无锡股份有限公司 | Method for acquiring and inquiring state monitoring data of wind turbine generator, and electronic equipment |
| CN113312374A (en) * | 2021-05-18 | 2021-08-27 | 网银在线(北京)科技有限公司 | Data query method, device, equipment and storage medium |
| CN114974605A (en) * | 2022-05-24 | 2022-08-30 | 山东浪潮智慧医疗科技有限公司 | Method for inquiring multiple nucleic acid reports in high-concurrency scene |
| CN117149802A (en) * | 2023-06-29 | 2023-12-01 | 南京维拓科技股份有限公司 | Statistical analysis method of industrial cloud application usage |
| CN117290411A (en) * | 2023-11-22 | 2023-12-26 | 深圳九有数据库有限公司 | Multimode database query method and device, electronic equipment and storage medium |
| CN117290411B (en) * | 2023-11-22 | 2024-02-13 | 深圳九有数据库有限公司 | Multimode database query method and device, electronic equipment and storage medium |
Also Published As
| Publication number | Publication date |
|---|---|
| CN109643305A (en) | 2019-04-16 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| WO2018035799A1 (en) | Data query method, application and database servers, middleware, and system | |
| US12443605B2 (en) | Generation of archiver queries for continuous queries over archived relations | |
| US12235874B2 (en) | Cross-organization and cross-cloud automated data pipelines | |
| EP2901321B1 (en) | Managing continuous queries with archived relations | |
| WO2020238597A1 (en) | Hadoop-based data updating method, device, system and medium | |
| CN106649630A (en) | Data query method and device | |
| CN104252501B (en) | A kind of computing device and method executing database manipulation order | |
| CN110019267A (en) | A kind of metadata updates method, apparatus, system, electronic equipment and storage medium | |
| CN107623729A (en) | A caching method, device and caching service system | |
| US10102230B1 (en) | Rate-limiting secondary index creation for an online table | |
| US20220413819A1 (en) | Code translations of resilient distributed datasets in databases | |
| CN104391868A (en) | Staticizing device and method for dynamic page | |
| CN112000734A (en) | A big data processing method and device | |
| US10445157B2 (en) | Concurrent services caching | |
| CN112347794B (en) | Data translation method, device, equipment and computer storage medium | |
| WO2019000897A1 (en) | Data acquisition method and device | |
| CN103957252B (en) | The journal obtaining method and its system of cloud stocking system | |
| CN109062929A (en) | A kind of query task communication means and system | |
| CN112181937A (en) | Data transmission method and device | |
| CN110019113B (en) | A database business processing method and database server | |
| CN115563183B (en) | Query method, query device and program product | |
| CN112783904A (en) | Method and device for updating index data | |
| CN117033748B (en) | Service query information acquisition method, service data query method and device | |
| US20250005194A1 (en) | Privacy Preserving Federated Query Engine | |
| CN117591592A (en) | Data source management method, device, electronic equipment and readable storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16913822 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 16913822 Country of ref document: EP Kind code of ref document: A1 |