Database access method, device, electronic device and computer storage medium
By setting up a database for storage of hot and cold data in the database, the problem of excessive data table space and high storage costs in the database system is solved, and efficient database access performance and cost reduction is achieved.
Patent Information
- Application Number
- CN201910759832.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-16
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2039-08-16
AI Technical Summary
With the increase of business data, the space of a single data table stored in the database system is too large, resulting in a decrease in application query performance and operation and maintenance performance. At the same time, cold data occupies a large amount of storage space, increasing storage costs.
By setting a first database for storing hot service data and a second database for storing at least part of cold service data in the database, and parsing the database access request, routing settings for the first database and the second database are performed, ensuring that the hot service data is stored separately, improving access performance and reducing storage costs.
It realizes separate storage of hot business data, improves database access performance, reduces storage costs, and avoids transformation of applications.
Smart Images

Figure CN112395265B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of computer technology, and in particular to a database access method, device, electronic device and computer storage medium. Background Art
[0002] With the rapid development of computer technology and the popularization of portable mobile devices, the business data generated by applications running on computers or portable mobile devices is becoming increasingly large. Usually, the business data of applications is stored in the database system. As the amount of business data increases, on the one hand, the space of a single data table stored in the database system becomes too large, which reduces the query performance and operation and maintenance performance of the application. On the other hand, there is a large amount of cold data with extremely low access frequency in the business data. These cold data occupy a large amount of storage space in the database system, resulting in very high storage costs.
[0003] Therefore, there is an urgent need for a database access solution that can ensure the database query performance of the application while minimizing the modification of the application and reducing the storage cost of the database system. Summary of the invention
[0004] In view of this, an embodiment of the present invention provides a database access solution to solve some or all of the above problems.
[0005] According to a first aspect of an embodiment of the present invention, a database access method is provided, comprising: determining a first database and / or a second database requested to be accessed by the database access request based on a parsing result of parsing a database access request, wherein the first database is used to store first business data within a set time period, and the second database is used to store second business data; performing a first routing setting for the first database on the parsing result, and / or performing a second routing setting for the second database on the parsing result; and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting.
[0006] According to a second aspect of an embodiment of the present invention, a database access device is provided, comprising: a first determination module, used to determine a first database and / or a second database requested to be accessed by the database access request based on a parsing result of parsing the database access request, wherein the first database is used to store first business data within a set time period, and the second database is used to store second business data; a routing setting module, used to perform a first routing setting for the first database on the parsing result, and / or, perform a second routing setting for the second database on the parsing result; an access module, used to access the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting.
[0007] According to a third aspect of an embodiment of the present invention, there is provided an electronic device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the database access method described in the first aspect.
[0008] According to a fourth aspect of an embodiment of the present invention, there is provided a computer storage medium on which a computer program is stored. When the program is executed by a processor, the database access method as described in the first aspect is implemented.
[0009] According to the database access solution provided by the embodiment of the present invention, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, separate storage of hot business data is achieved to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present invention. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0011] Figure 1 A flowchart of a method for accessing a database according to a first embodiment of the present invention;
[0012] Figure 2 A flowchart of a method for accessing a database according to Embodiment 2 of the present invention;
[0013] Figure 3 A flowchart of a method for accessing a database according to Embodiment 3 of the present invention;
[0014] Figure 4 is a flowchart of a method for accessing a database according to a fourth embodiment of the present invention;
[0015] Figure 5 This is a flowchart of a method for accessing a database according to Embodiment 5 of the present invention;
[0016] Figure 6 A schematic diagram of the structure of a database according to a usage scenario of the present invention;
[0017] Figure 7 A flowchart of the steps of a database access method according to a usage scenario of the present invention;
[0018] Figure 8 is a structural block diagram of a database access device according to Embodiment 6 of the present invention;
[0019] Fig. 9 is a structural block diagram of a database access device according to Embodiment 7 of the present invention;
[0020] Fig.10 FIG. 4 is a schematic diagram of the structure of an electronic device according to Embodiment 8 of the present invention. DETAILED DESCRIPTION
[0021] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. All other embodiments obtained by ordinary technicians in the field based on the embodiments in the embodiments of the present invention should fall within the scope of protection of the embodiments of the present invention.
[0022] The specific implementation of the embodiment of the present invention is further described below in conjunction with the accompanying drawings of the embodiment of the present invention.
[0023] Embodiment 1
[0024] Reference Figure 1 , shows a step flow chart of a database access method according to embodiment 1 of the present invention.
[0025] The database access method of this embodiment includes the following steps:
[0026] Step S102: Determine the first database and / or the second database requested to be accessed by the database access request according to the analysis result of the database access request.
[0027] In this embodiment, the first database is used to store the first business data within a set time period, wherein the first database can represent a hot storage, and the set time period can be set by those skilled in the art according to actual needs, for example, the set time period can be the last three months, the last week, etc. The second database is used to store the second business data, and the second business data includes at least part of the cold business data. For example, the second business data can be all business data other than the first business data, or can be the full amount of business data including the first business data, or can be part of the cold business data. The second database can represent a cold storage.
[0028] By configuring the first database and the second database in the database system, the first database is used to store the first business data (i.e., hot business data) with a high access frequency and / or access probability, and the second database is used to store the second business data (e.g., full business data), which not only ensures the storage of cold business data, but also realizes the distinction between the hot and cold attributes of business data. Using an independent first database to store hot business data can effectively reduce the amount of stored data, thereby improving the query and / or processing performance, and further improving the operation and maintenance performance of the database.
[0029] Furthermore, since the total amount of hot business data is small, it can be stored in a storage medium with a fast read and write speed, such as a solid-state drive (SSD), to further ensure the access performance of the hot business data without making the storage cost of the database too high. The access performance includes but is not limited to query performance, modification performance, addition performance and deletion performance.
[0030] Optionally, in this embodiment, the second database uses a storage medium with a slower read / write speed than the first database to store at least part of the cold business data or the full business data. For example, the storage medium used by the second database may be a disk to further reduce the storage cost of the database.
[0031] In this embodiment, the database access request is used to indicate an access operation to business data in the database, such as reading data, modifying data, adding data, and deleting data.
[0032] After receiving the database access request, the request is parsed to obtain the parsing result, and then the database to be accessed by the database access request is determined according to the parsing result, and then the database access request is routed to the corresponding first database and / or second database in the subsequent steps. For the user, there is no need to understand the specific data storage situation, and the implementation details of the separate storage of cold and hot business data are shielded from the user, thereby improving the user experience.
[0033] Step S104: performing a first routing setting for the first database on the parsing result, and / or performing a second routing setting for the second database on the parsing result.
[0034] The parsing results are routed accordingly based on the database that needs to be accessed, so that they can be accurately and quickly routed to the corresponding database.
[0035] The routing settings for the parsing results may be different depending on the database that needs to be accessed.
[0036] For example, in case A, if it is determined according to the analysis result that only the first database needs to be accessed, step S104 is implemented as follows: a first routing setting for the first database is performed on the analysis result. The first routing setting includes but is not limited to adding a filter condition for the first database to the SQL statement of the analysis result. The filter condition may be a filter condition for indicating the creation time of the filter, or a filter condition for indicating the primary key value of the filter, or a condition for indicating that the business data to be accessed is hot business data, etc.
[0037] For another example, in case B: if it is determined according to the analysis result that only the second database needs to be accessed, step S104 is implemented as follows: a second routing setting for the second database is performed on the analysis result. The second routing setting includes but is not limited to adding a filtering condition for the second database to the SQL statement of the analysis result. The filtering condition can be determined by a person skilled in the art as needed, and this embodiment does not limit this. For example, the filtering condition can be a filtering condition for indicating the filter creation time, a filtering condition for indicating the primary key value, or a condition for indicating that the business data to be accessed is cold business data, etc.
[0038] For another example, in case C: if it is determined according to the analysis result that both the first database and the second database need to be accessed, step S104 is implemented as: setting a first route for the first database for the analysis result, and setting a second route for the second database for the analysis result.
[0039] In case C, the same first routing setting method and second routing setting method as those in case A and case B may be adopted, or a method different from those in case A and case B may be adopted, which will not be described in detail here.
[0040] By setting targeted routing for the parsing results based on the database that needs to be accessed, it is possible to intelligently route database access requests while independently storing hot business data without making changes to the application, thereby improving the applicability of the database, improving the database access performance, and improving the user experience of using the application.
[0041] Step S106: Access the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting.
[0042] After performing the first routing setting and / or the second routing setting on the parsing result, the corresponding first database and / or the second database may be accessed according to the first routing result and / or the second routing result.
[0043] For example, for situation A in step S104 (i.e., only the first database needs to be accessed), step S106 can route the result of the first routing setting to the first database, thereby accessing the business data in the first database and obtaining the request result of the database access request.
[0044] For another example, for situation B in step S104 (i.e., only the second database needs to be accessed), step S106 can be implemented by routing the result of the second routing setting to the second database, thereby accessing the business data in the second database and obtaining the request result of the database access request.
[0045] For another example, with respect to situation C in step S104 (i.e., access to the first database and the second database is required), step S106 can be implemented by routing the result of the first routing setting and the result of the second routing setting to the first database and / or the second database accordingly, so as to perform access operations on the business data in the first database and the second database, and obtain the request result of the database access request.
[0046] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, hot business data is stored separately to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0047] The database access method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as tablet computers, mobile phones, etc.) and PCs, etc.
[0048] Embodiment 2
[0049] Reference Figure 2 , shows a step flow chart of a database access method according to embodiment 2 of the present invention.
[0050] The database access method of this embodiment includes the aforementioned steps S102 to S106.
[0051] In this embodiment, step S102 includes the following sub-steps:
[0052] Sub-step S1021: determining, based on the analysis result of analyzing the database access request, whether the analysis result includes a time filtering condition indicating the creation time of filtering the business data.
[0053] The time filter condition is used to indicate the creation time of the business data to be accessed by the database access request. According to the time filter condition and the cold and hot time division point T, it can be determined whether the business data to be accessed is cold business data or hot business data or both, and then the database to be accessed can be determined.
[0054] The hot and cold time division point (denoted as T) is used to distinguish the hot and cold attributes of business data, which can be the current time minus the set time period. For example, the set time period is the last 3 months, T = (now()-3 months).
[0055] Taking the case where the parsed result includes an SQL statement as an example, the time filtering condition can be included in the WHERE clause of the SQL statement as a condition. It can adopt any appropriate representation form according to needs. For example, it can be expressed as gmtCreate >= T1, or as gmtCreate < T2, and so on. Here, T1 and T2 are the time obtained by subtracting the period to be queried from the current moment. The period to be queried can be set according to needs. For example, the period to be queried corresponding to T1 is the most recent week, and the period to be queried corresponding to T2 is three years ago, etc.
[0056] In the first case, the database access request includes a time filtering condition, and according to the time filtering condition and the cold and hot time division point T, it is determined whether the business data to be accessed is cold business data or hot business data, and then step S1022 is executed. For example, if the database access request is: SELECT * FROM TB WHERE gmt_Create >= T1 and T1 >= T (i.e., now() - 3 months), then only the hot database needs to be accessed, and the cold database does not need to be accessed. For example, if the database access request is: SELECT * FROM TB WHERE gmt_Create < T2 and T2 <= T (i.e., now() - 3 months), then only the cold database needs to be accessed, and the hot database does not need to be accessed.
[0057] In the second case, the database access request includes a time filtering condition, and according to the time filtering condition and the cold and hot time division point T, it is determined that the business data to be accessed includes both cold business data and hot business data, then it is determined to access the first database and the second database.
[0058] In the third case, the database access request does not include a time filtering condition, then it may be necessary to access cold business data and hot business data, and step S1023 is executed.
[0059] In this way, it is possible to automatically determine the time range of the time filtering condition and determine whether to access the first database and / or the second database according to the time range.
[0060] Sub-step S1022: If the time filtering condition is included, then according to the time filtering condition, it is determined to access the first database or the second database.
[0061] In the case where a time filtering condition is included, if it is determined according to the time filtering condition that the business data to be accessed is cold business data. For example, the time filtering condition is gmtCreate < T2, where T2 < T, then it is determined to access the second database. If it is determined according to the time filtering condition that the business data to be accessed is hot business data. For example, the time filtering condition is gmtCreate > T1, where T1 > T, then it is determined to access the first database.
[0062] Sub-step S1023: If the time screening condition is not included, determine to request access to the first database and the second database.
[0063] When the time filter condition is not included, it indicates that cold business data and hot business data may need to be accessed, and in this case, it is determined to access the first database and the second database.
[0064] In summary, when the database includes the first database and the second database, the aforementioned implementation method can be used to implement intelligent routing, so that the separation of hot and cold business data in the database is almost transparent to the application, making the application access very convenient.
[0065] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, hot business data is stored separately to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0066] The database access method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as tablet computers, mobile phones, etc.) and PCs, etc.
[0067] Embodiment 3
[0068] Reference Figure 3 , shows a step flow chart of a database access method according to embodiment three of the present invention.
[0069] The database access method of this embodiment includes the aforementioned steps S102 to S106, wherein the step S102 may be implemented in the manner of the first or second embodiment, or in other implementations.
[0070] In this embodiment, the routing setting includes a time filter setting, wherein step S104 may include: performing a first time filter setting on the parsing result for the first database; and / or performing a second time filter setting on the parsing result for the second database.
[0071] In this embodiment, the implementation process of step S104 may include the following situations:
[0072] Case A: When only the first database needs to be accessed, a method for implementing a first time filter setting for the first database on the analysis result is: rewriting the SQL statement in the analysis result according to the first time filter condition corresponding to the first database to generate a first SQL statement.
[0073] Among them, the first time filtering condition is greater than or equal to the cold and hot time division point, so that the first time filtering setting can indicate the filtering of business data whose creation time is within the set time period, thereby limiting the database access request routed to the first database to only access the business data whose creation time is within the set time period.
[0074] Take the creation time of business data recorded using the gmtCreate field, set the time period to the last three months, and the SQL statement in the parsing result as: SELECT*FROM TB WHERE ID=1 as an example; the first time screening condition can be expressed as gmtCreate>=T, that is, the creation time of the business data is greater than or equal to the hot and cold time dividing point, and the rewritten first SQL statement can be: SELECT*FROM TB WHERE ID=1 AND gmtCreate>=T.
[0075] It should be noted that, when the SQL statement of the parsing result includes a time filter condition, the range of the original time filter condition and the first time filter condition can be determined during rewriting, and the smaller range shall prevail.
[0076] The first SQL statement may be a physical SQL corresponding to the first database generated by performing routing settings after rewriting the SQL statement in the parsing result and optimizing the specific query strategy.
[0077] Case B: When only the second database needs to be accessed, a method for implementing a second time filter setting for the second database on the analysis result is: rewriting the SQL statement in the analysis result according to the second time filter condition corresponding to the second database to generate a second SQL statement.
[0078] Among them, the second time filtering condition is less than the cold and hot time dividing point, so that the second time filtering setting can indicate the filtering of business data whose creation time is outside the set time period, thereby limiting the database access request routed to the second database to only access the business data whose creation time is within the set time period.
[0079] Still taking the record of the creation time of business data using the gmtCreate field as an example, with the set time period being the most recent 3 months, and the SQL statement in the parsing result being: SELECT * FROM TB WHERE ID = 1; the second time filtering condition can be expressed as gmtCreate < T, that is, the creation time of business data is less than the hot and cold time segmentation point. The rewritten second SQL statement can be: SELECT * FROM TB WHERE ID = 1 AND gmtCreate < T.
[0080] It should be noted that when the SQL statement in the parsing result includes a time filtering condition, when rewriting, the ranges of the original time filtering condition and the second time filtering condition can be judged, and the smaller one shall prevail.
[0081] The second SQL statement can be the physical SQL of the corresponding second database generated after rewriting the SQL statement in the parsing result and optimizing the specific query strategy and then performing routing settings.
[0082] Case C: When it is necessary to access the first database and the second database, the implementation method of the first time filtering setting for the parsing result for the first database can be the same as or different from the aforementioned Case A, and the implementation method of the second time filtering setting for the second database can be the same as or different from the aforementioned Case B.
[0083] By performing time filtering settings on the parsing result, it can be strictly limited that the SQL statement for accessing the first database is only responsible for processing business data that meets the first time filtering condition, and the SQL statement for accessing the second database is only responsible for processing business data that meets the second time filtering condition, thus avoiding the problem that duplicate business data in the first database and the second database may affect the accuracy of accessing business data.
[0084] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of the cold business data in the database, separate storage of hot business data is realized to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database on the parsing result of the database access request, and accessing the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting, it is ensured that on the premise of meeting the database access request, the implementation details of the separate storage of hot and cold business data are shielded from the application program, thus achieving the purpose of improving the access performance of the database and reducing the storage cost without modifying the application program.
[0085] The database access method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as tablet computers, mobile phones, etc.) and PCs, etc.
[0086] Embodiment 4
[0087] Reference Figure 4 , shows a step flow chart of a database access method according to embodiment 4 of the present invention.
[0088] The database access method of this embodiment includes the aforementioned steps S102 to S106. The step S102 may be implemented in the first or second embodiment, or in other implementations. The step S104 may be implemented in the first or third embodiment, or in other implementations.
[0089] In the case where it is determined in step S102 to access the first database and the second database, since the reading and writing speed of the storage medium of the second database is relatively low and the amount of business data stored in the second database is relatively large, the access performance is affected and the efficiency is relatively low.
[0090] In order to solve the aforementioned problem, if it is determined that a request is made to access the first database and the second database, and the database access request also includes a result screening condition that limits the access result, that is, if it is determined that access is required across the cold storage and the hot storage, and the database access request includes the result screening condition, a strategy of preferentially accessing the first database is adopted. At this time, step S106 includes the following sub-steps:
[0091] Sub-step S1061: accessing the first database according to the result of the first routing setting to obtain a first access result.
[0092] If the first access result of the first database meets the result screening condition, sub-step S1062 is executed to directly not access the second database, so as to avoid affecting the overall access performance of the database access request due to the poor access performance of the second database.
[0093] Alternatively, if the first access result of the first database cannot satisfy the result screening condition, sub-step S1063 and sub-step S1064 are executed to ensure that the access result satisfying the result screening condition can be obtained.
[0094] Sub-step S1062: If the first access result satisfies the result screening condition, generating a request response result for responding to the database access request according to the first access result.
[0095] The result screening conditions can be set by those skilled in the art for different screening purposes according to actual needs. In one feasible manner, the result screening conditions can be used to limit the number of access results. For example, it can be a LIMIT clause for limiting the number of results returned, or a HINT clause for limiting the number of results affected.
[0096] Taking the database access request including a LIMIT clause or a HINT clause as an example, if the number of first access results of accessing the first database meets the number limited by the LIMIT clause or the HINT clause, there is no need to access the second database, and a request response result in response to the database access request can be directly generated based on the first access result.
[0097] Sub-step S1063: if the first access result does not satisfy the result screening condition, access the corresponding second database according to the result of the second routing setting to obtain a second access result.
[0098] Taking the database access request including a LIMIT clause (used to limit the number of results returned) or a HINT clause (used to limit the number of hit results) as an example, if the number of the first access results does not meet the result screening condition, it is necessary to continue to access the second database to obtain the second access result.
[0099] It should be noted that in order to prevent duplicate data in the first database and the second database from affecting the accuracy of the second access result, the result of the second route setting includes a second time screening condition to limit access to the second database and only access cold business data in the second database. This reduces the amount of business data when accessing the second database, which helps to improve access performance, and ensures the accuracy of the second access result, preventing duplicate data from existing in the first access result and the second access result.
[0100] Sub-step S1064: Generate a request response result for responding to the database access request according to the second access result and the first access result.
[0101] After obtaining the first access result and the second access result, a request response result for responding to the database access request is generated by combining the first access result and the second access result.
[0102] In summary, when determining the strategy for accessing the first database and / or the second database, it is determined whether to access the first database alone according to whether the database access request contains a time filter condition.
[0103] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, hot business data is stored separately to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0104] The database access method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as tablet computers, mobile phones, etc.) and PCs, etc.
[0105] Embodiment 5
[0106] Reference Figure 5 , shows a step flow chart of a database access method according to Embodiment 5 of the present invention.
[0107] The database access method of this embodiment includes the aforementioned steps S102 to S106. Among them, the step S102 can adopt the implementation method of the first or second embodiment, or adopt other implementation methods. The step S104 can adopt the implementation method of the first or third embodiment, or adopt other implementation methods. The step S106 can adopt the implementation method of the first or fourth embodiment, or adopt other implementation methods.
[0108] In this embodiment, the method further includes:
[0109] Step S108: According to the received adjustment request, the configuration parameter indicating the set time period is adjusted.
[0110] The adjustment request is used to instruct to adjust the hot and cold time division point, that is, to adjust the set time period of the first database, for example, to adjust the set time period from the last three months to the last week, or to the last year, etc.
[0111] The configuration parameters for indicating the set time period can be saved in a configuration file. In this case, the configuration parameters can be adjusted by modifying the configuration file. Of course, in other embodiments, the configuration parameters can be saved in other ways, and accordingly, they can be modified in a matching way, which is not limited in this embodiment.
[0112] In this embodiment, since the configuration parameter indicating the set time period can be adjusted according to the adjustment request, the hot and cold attributes of the business data can be defined according to the business dimension, which has better adaptability.
[0113] Optionally, the method may further include:
[0114] Step S110: Migrate at least part of the business data in the first database to the second database.
[0115] As time goes by or after the hot and cold time division points are adjusted according to a mediation request, the hot and cold attributes of the business data will change, causing at least part of the first business data in the first database to become cold business data. Therefore, this part of the business data can be migrated to the second database for storage, thereby maintaining the amount of business data in the first database within a relatively stable range to prevent excessive storage costs or reduced access performance.
[0116] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, hot business data is stored separately to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0117] The database access method of this embodiment can be executed by any appropriate electronic device with data processing capabilities, including but not limited to: servers, mobile terminals (such as tablet computers, mobile phones, etc.) and PCs, etc.
[0118] Use scenarios:
[0119] The following takes an IM program (instant messaging program) as an example to illustrate the process of the database access method.
[0120] Among them, Figure 6 As shown, the databases accessed by the IM program include the SQL engine, intelligent routing component, hot storage, cold storage, and data migration component.
[0121] The SQL engine is used to parse, optimize, and execute SQL for database access requests. The SQL engine of the database shields the application from the database settings and storage details, and externally encapsulates itself into a standardized MySQL database service. For example, it can be encapsulated into a service protocol or service domain name, and the application accesses the database through the service protocol name or service domain name, and the corresponding access port.
[0122] The intelligent routing component is used to determine the routing and execution strategy based on the analysis results, that is, to determine the access to the hot storage and / or cold storage, etc. The intelligent routing component can be configured on the same device as the SQL engine, or on a different device. The intelligent routing component includes a configuration file, which stores information such as the hot and cold time segmentation points. The business can adjust the hot and cold time segmentation points by modifying the configuration file as needed, that is, adjust the set time period.
[0123] The hot database stores business data within a set time period, usually hot business data after the hot and cold time division point. The hot database uses storage media with fast read and write speeds to store business data to ensure that it has good access performance.
[0124] Cold storage is used to store the full amount of business data, usually using low-cost storage with compression. Its access performance may be one order of magnitude or more lower than that of hot storage.
[0125] The data migration component is used to migrate business data from the hot storage to the cold storage in batches at regular intervals.
[0126] based on Figure 6 For a database with the structure shown, the process of performing database access for a database access request includes the following steps:
[0127] Step A: parse the database access request to obtain the parsing result.
[0128] For example, the SQL engine obtains a database access request from an application, parses the database access request, and optimizes the parsed result to generate an execution plan. For example, SELECT*FROM TB WHERE ID=1LIMIT2, where TB is the data table name, ID is the field name, and LIMIT 2 is used to limit the number of expected query results.
[0129] Step B: Determine to access the hot storage and / or cold storage based on the analysis results.
[0130] The intelligent routing component calculates the routing results based on the specific content of the SQL engine's execution plan. The specific process of obtaining the routing results includes:
[0131] Case 1: When the SQL statement contains a time filtering condition (i.e., there is a WHERE clause in the SQL statement and the WHERE clause contains a condition related to gmtCreate), it is determined to route to the hot database or the cold database.
[0132] For example, for SELECT*FROM TB WHERE ID=1 AND gmtCreate>T1 LIMIT 2 (where TB is the data table name, ID and gmtCreate are field names, T1>T, and T is the hot and cold time division point), since this SQL statement contains gmtCreate>T1 and T1>T, this is a request to access hot business data and needs to be routed to the hot database.
[0133] Another example, for SELECT*FROM TB WHERE ID=1 AND gmtCreate<T2 LIMIT 2 (where TB is the data table name, ID and gmtCreate are field names, T2<T, and T is the hot and cold time division point), since this SQL statement contains gmtCreate<T2 and T2<T, this is a request to query only cold business data and only needs to be routed to the cold database.
[0134] Case 2: When the SQL statement does not contain a time filtering condition (i.e., it does not contain a condition related to GMTCREAT), it is determined to route to the hot database and the cold database.
[0135] For example, for the aforementioned SELECT*FROM TB WHERE ID=1 LIMIT 2 (where TB is the data table name and ID is the field name), since this SQL statement has no time filtering condition, it is necessary to access both the hot database and the cold database.
[0136] Step C: Perform the first routing setting for the hot database on the parsing result, and / or perform the second routing setting for the cold database on the parsing result.
[0137] For example, for the case of accessing the hot database in Case 1 of Step B, for each SQL statement in the execution plan of the parsing result, rewrite it using the first time filtering condition (gmtCreate>=T) or the condition with a smaller range in the original time filtering condition, and generate the physical SQL statement (i.e., the first SQL statement) for the physical layer of the hot database. The first SQL statement is SELECT*FROM TB WHERE ID=1 AND gmtCreate>=T LIMIT 2.
[0138] Since each SQL statement in the parsing result is pushed down to the physical layer to generate physical SQL statements, and the physical SQL statements may not contain time filtering conditions, in order to ensure that each SQL statement can process business data within the corresponding creation time, it is necessary to add appropriate time filtering conditions to the physical SQL statements.
[0139] For another example, in the case of accessing the cold storage in Case 1 of Step B, for each SQL statement in the execution plan of the parsing result, rewrite it using the second time filtering condition (gmtCreate < T) or the condition with a smaller range in the original time filtering conditions, and generate the physical SQL statement (i.e., the second SQL statement) for the physical layer of the cold storage. The second SQL statement is SELECT * FROM TB WHERE ID = 1 AND gmtCreate < T LIMIT 2.
[0140] Since each SQL statement in the parsing result is pushed down to the physical layer to generate physical SQL statements, and the physical SQL statements may not contain time filtering conditions, in order to ensure that each SQL statement can process business data within the corresponding creation time, it is necessary to add appropriate time filtering conditions to the physical SQL statements.
[0141] For yet another example, in the case of accessing the hot storage and the cold storage in Case 2 of Step B, for each SQL statement in the execution plan of the parsing result, rewrite it using the first time filtering condition and the second time filtering condition, and generate the first SQL statement for the hot storage (limiting that the SQL statement for accessing the hot storage is only responsible for processing business data with a creation time after the hot-cold time split point) and the second SQL statement for the cold storage (limiting that the SQL statement for accessing the hot storage is only responsible for processing business data with a creation time before the hot-cold time split point).
[0142] In the case of accessing the hot storage and the cold storage, usually the SQL statements in the parsing result do not contain time filtering conditions, or the time filtering conditions span the hot storage and the cold storage. Therefore, in order to ensure that each SQL statement can process business data within the corresponding creation time, it is necessary to add appropriate time filtering conditions to the physical SQL statements.
[0143] By automatically adding the condition gmtCreate >= T to all physical SQL statements sent to the hot storage; and automatically adding the condition gmtCreate < T to all physical SQL statements sent to the cold storage, the problem of duplicate business data between the hot storage and the cold storage can be solved.
[0144] Step D: Access the hot storage according to the result of the first routing setting, and / or access the cold storage according to the result of the second routing setting.
[0145] For example, in the case where only the hot database needs to be accessed, the hot database is directly routed according to the result of the first routing setting (i.e., the first SQL statement), and the first access result is obtained. The intelligent routing component sends the first access result to the SQL engine, which sends it to the application.
[0146] For another example, in the case where only the cold storage needs to be accessed, the result of the second routing setting (i.e., the second SQL statement) is directly routed to the cold storage, and the second access result is obtained. The intelligent routing component sends the second access result to the SQL engine, which performs a secondary calculation on the first access result as needed or does not process it, and then sends it to the application.
[0147] For another example, in the case where the hot storage and cold storage need to be accessed, if the database access request includes a result screening condition (such as LIMIT 2 or HINT 2, etc.), the hot storage is first accessed according to the result of the first routing setting, and it is determined whether it can meet the result screening condition based on the first access result. If it does, the intelligent routing component sends the first access result to the SQL engine, which performs subsequent processing and sends it to the application; if it does not meet, the cold storage is accessed according to the result of the second routing setting to obtain the second access result. The intelligent routing component merges the first access result and the second access result and sends it to the SQL engine, which performs secondary calculations on the first access result and the second access result as needed or does not process them, and then sends them to the application. Secondary calculations include but are not limited to unified sorting or summing of the first access result and the second access result in the SQL engine.
[0148] If the database access request does not include a filter condition, the hot database and the cold database may be accessed separately, and the first access result and the second access result may be obtained and then merged and sent to the application.
[0149] Step E: Migrate at least part of the business data in the hot storage to the cold storage.
[0150] This step is an optional step and can be performed before, after or at any appropriate time during steps A to D.
[0151] The data migration component periodically migrates the business data that has become cold business data in the hot storage to the cold storage for safekeeping.
[0152] like Figure 7 As shown, a specific process of processing a query request sent by an application program (APP) is as follows:
[0153] S1: The application (APP) sends a query SQL (SELECT query) to the SQL engine.
[0154] S2: Generate an execution plan based on SQL syntax.
[0155] S3: Determine the route of the cold storage or hot storage and the execution strategy of the cold storage or hot storage according to the execution plan. In this strategy, the hot storage is queried first.
[0156] S4: Generate physical SQL for the hot database and automatically add the WHERE condition that gmtCreate is greater than or equal to T.
[0157] S5: Physical SQL queries the hot database.
[0158] S6: Hot database returns query results
[0159] S7: If the SQL statement has a LIMIT clause, and the number of query results returned by the hot storage meets the LIMIT, the query returns directly and jumps to S11; if the number of query results returned by the hot storage does not meet the LIMIT, the query continues to be made in the cold storage (execute S8).
[0160] S8: Generates physical SQL for the cold storage and automatically adds the condition that gmtCreate is less than T.
[0161] S9: Physical SQL query in cold storage.
[0162] S10: The cold storage returns the query result.
[0163] S11: Return the physical query result to the SQL engine.
[0164] S12: Merge the query results of the cold storage and the hot storage, and return them to the application in a unified manner.
[0165] It should be noted that when a database access request is made to write data, in step D, before accessing the hot storage according to the result of the first routing setting and / or accessing the cold storage according to the result of the second routing setting, the intelligent routing component starts an XA transaction (distributed transaction) to ensure data consistency in the hot storage and / or cold storage.
[0166] In this usage scenario, the database access method achieves the purpose of completely shielding the details of hot and cold data separation on the application side based on the SQL engine and intelligent routing components. The application only needs to access the database according to the standard MYSQL protocol, making access very convenient.
[0167] To ensure access performance, hot storage usually uses SSD as storage medium, while cold storage uses lower-cost mechanical disks (such as SATA disks) as storage medium, and compresses and saves cold business data to reduce storage costs.
[0168] Through the intelligent routing component, accurate routing and execution optimization of hot and cold storage are achieved, which can greatly reduce the impact of cold storage queries on performance. It can automatically add first-time filtering conditions or second-time filtering conditions to all physical SQL statements, effectively solving the problem of incorrect results caused by repeated data in hot and cold storage.
[0169] The execution plan generated by the SQL engine and the hot and cold routing judgment of the intelligent routing component can effectively support complex SQL queries that need to cross hot and cold storage. The precise hot and cold storage routing and execution strategy optimization based on the intelligent routing component can effectively avoid the degradation of read and write performance caused by most SQL queries going through cold storage.
[0170] By modifying the configuration file, the hot and cold attributes of business data can be defined according to business dimensions.
[0171] Embodiment 6
[0172] Reference Figure 8 , shows a structural block diagram of a database access device according to embodiment 6 of the present invention.
[0173] The database access device of this embodiment includes: a first determination module 802, which is used to determine the first database and / or the second database requested to be accessed by the database access request according to the parsing result of parsing the database access request, wherein the first database is used to store first business data within a set time period, and the second database is used to store second business data; a routing setting module 804, which is used to perform a first routing setting for the first database on the parsing result, and / or, perform a second routing setting for the second database on the parsing result; an access module 806, which is used to access the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting.
[0174] Through this embodiment, by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, hot business data is stored separately to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0175] Embodiment 7
[0176] Reference Fig. 9 , shows a structural block diagram of a database access device according to Embodiment 7 of the present invention.
[0177] The database access device of this embodiment includes: a first determination module 902, which is used to determine the first database and / or the second database requested to be accessed by the database access request according to the parsing result of parsing the database access request, wherein the first database is used to store first business data within a set time period, and the second database is used to store second business data; a routing setting module 904, which is used to perform a first routing setting for the first database on the parsing result, and / or, perform a second routing setting for the second database on the parsing result; an access module 906, which is used to access the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting.
[0178] Optionally, the routing setting module 904 is used to perform a first time filtering setting on the parsing results for the first database; and / or, to perform a second time filtering setting on the parsing results for the second database; wherein the first time filtering setting is used to indicate filtering of business data whose creation time is within the set time period, and the second time filtering setting is used to indicate filtering of business data whose creation time is outside the set time period.
[0179] Optionally, the device further includes: an adjustment module 908, configured to adjust a configuration parameter indicating the set time period according to a received adjustment request.
[0180] Optionally, the first determination module 902 includes: a second determination module 9021, used to determine whether the analysis result contains a time filtering condition indicating the creation time of the filtered business data based on the analysis result; a third determination module 9022, used to determine whether to access the first database or the second database based on the time filtering condition if it contains the time filtering condition.
[0181] Optionally, the first determining module 902 further includes: a fourth determining module 9023, configured to determine a request to access the first database and the second database if the time filtering condition is not included.
[0182] Optionally, the access module 906 includes: a first routing module 9061, which is used to access the first database according to the result of the first routing setting to obtain a first access result when it is determined that a request is made to access the first database and the second database, and the database access request also includes a result filtering condition that limits the access result; and a first generation module 9062, which is used to generate a request response result for responding to the database access request according to the first access result if the first access result satisfies the result filtering condition.
[0183] Optionally, the access module 906 also includes: a second routing module 9063, which is used to access the corresponding second database according to the result of the second routing setting to obtain a second access result if the first access result does not meet the result screening condition; a second generation module 9064, which is used to generate a request response result for responding to the database access request based on the second access result and the first access result.
[0184] Optionally, the second business data is the full amount of business data including the first business data; and / or the reading and writing speed of the storage medium used by the first database is greater than the reading and writing speed of the storage medium used by the second database.
[0185] The database access device of this embodiment is used to implement the corresponding database access methods in the aforementioned multiple method embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be described in detail here.
[0186] Embodiment 8
[0187] Reference Fig.10 , shows a schematic diagram of the structure of an electronic device according to Embodiment 8 of the present invention. The specific embodiment of the present invention does not limit the specific implementation of the electronic device.
[0188] like Fig.10 As shown, the electronic device may include: a processor (PROCESSOR) 1002 , a communication interface (COMMUNICATIONS INTERFACE) 1004 , a memory (MEMORY) 1006 , and a communication bus 1008 .
[0189] in:
[0190] The processor 1002 , the communication interface 1004 , and the memory 1006 communicate with each other via a communication bus 1008 .
[0191] The communication interface 1004 is used to communicate with other electronic devices such as terminal devices or servers.
[0192] The processor 1002 is used to execute the program 1010, and specifically can execute the relevant steps in the above-mentioned database access method embodiment.
[0193] Specifically, the program 1010 may include program codes, which include computer operation instructions.
[0194] The processor 1002 may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the electronic device may be processors of the same type, such as one or more CPUs; or may be processors of different types, such as one or more CPUs and one or more ASICs.
[0195] The memory 1006 is used to store the program 1010. The memory 1006 may include a high-speed RAM memory, and may also include a non-volatile memory (NON-VOLATILE MEMORY), such as at least one disk memory.
[0196] Program 1010 can be specifically used to enable processor 1002 to perform the following operations: determine the first database and / or second database requested to be accessed by the database access request based on the parsing result of parsing the database access request, wherein the first database is used to store first business data within a set time period, and the second database is used to store second business data; perform a first routing setting for the first database on the parsing result, and / or perform a second routing setting for the second database on the parsing result; access the corresponding first database and / or second database based on the result of the first routing setting and / or the result of the second routing setting.
[0197] In an optional embodiment, program 1010 is also used to enable processor 1002 to perform a first time filtering setting for the first database on the parsing result when performing a first routing setting for the first database on the parsing result and / or performing a second routing setting for the second database on the parsing result; and / or performing a second time filtering setting for the second database on the parsing result; wherein the first time filtering setting is used to indicate filtering of business data whose creation time is within the set time period, and the second time filtering setting is used to indicate filtering of business data whose creation time is outside the set time period.
[0198] In an optional implementation, the program 1010 is further configured to enable the processor 1002 to adjust a configuration parameter indicating the set time period according to a received adjustment request.
[0199] In an optional embodiment, program 1010 is also used to enable processor 1002 to determine, based on the parsing result of parsing the database access request, the first database and / or the second database requested to be accessed by the database access request, and determine, based on the parsing result, whether the parsing result contains a time filtering condition indicating the creation time of the filtered business data; if it contains the time filtering condition, determine to access the first database or the second database based on the time filtering condition.
[0200] In an optional embodiment, program 1010 is also used to enable processor 1002 to determine the first database and / or second database requested to be accessed by the database access request based on the analysis result of parsing the database access request, and if the time filtering condition is not included, determine to request access to the first database and the second database.
[0201] In an optional embodiment, when it is determined that a request is made to access the first database and the second database, and the database access request also includes a result filtering condition that limits the access result, the program 1010 is also used to enable the processor 1002 to access the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting, and to access the first database according to the result of the first routing setting to obtain a first access result; if the first access result satisfies the result filtering condition, then a request response result for responding to the database access request is generated according to the first access result.
[0202] In an optional embodiment, program 1010 is also used to enable processor 1002 to access the corresponding second database according to the result of the second routing setting to obtain a second access result if the first access result does not meet the result screening condition; and generate a request response result for responding to the database access request based on the second access result and the first access result.
[0203] In an optional implementation, the second business data is the full amount of business data including the first business data; and / or the reading and writing speed of the storage medium used by the first database is greater than the reading and writing speed of the storage medium used by the second database.
[0204] The specific implementation of each step in program 1010 can refer to the corresponding description of the corresponding steps and units in the above-mentioned database access method embodiment, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiment, which will not be repeated here.
[0205] The electronic device of this embodiment realizes separate storage of hot business data by setting a first database for storing hot business data and a second database for storing at least part of cold business data in the database, so as to improve the access performance of the database and avoid making the storage cost of the database too high. By performing a first routing setting for the first database and / or a second routing setting for the second database based on the parsing result of the database access request, and accessing the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting, it is ensured that the implementation details of the separate storage of hot and cold business data are shielded from the application program under the premise of satisfying the database access request, thereby achieving the purpose of improving the access performance of the database without modifying the application program and reducing the storage cost.
[0206] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present invention can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present invention.
[0207] The above-described method according to an embodiment of the present invention may be implemented in hardware, firmware, or as software or computer code that can be stored in a recording medium (such as a CD ROM, RAM, floppy disk, hard disk, or magneto-optical disk), or as computer code that is originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded through a network and will be stored in a local recording medium, so that the method described herein may be stored in such software processing on a recording medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware (such as an ASIC or FPGA). It is understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor, or hardware, the database access method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the database access method shown herein, the execution of the code converts the general-purpose computer into a dedicated computer for executing the database access method shown herein.
[0208] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present invention.
[0209] The above implementation methods are only used to illustrate the embodiments of the present invention, and are not limitations of the embodiments of the present invention. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present invention. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present invention. The patent protection scope of the embodiments of the present invention should be defined by the claims.
Claims
1. A database access method, characterized in that: Applied to a database system, wherein a first database and a second database are configured in the database system, including: Parsing the database access request to obtain a parsing result; Determine, according to whether the parsing result contains a time screening condition for indicating the creation time of the screened business data, a first database and / or a second database requested to be accessed by the database access request, wherein the first database is used to store the first business data within a set time period, and the second database is used to store the second business data; Performing a first routing setting for the first database on the parsing result, and / or performing a second routing setting for the second database on the parsing result; the first routing setting includes setting a screening condition for the first database on the parsing result; the second routing setting includes setting a screening condition for the second database on the parsing result; According to the result of the first routing setting and / or the result of the second routing setting, the corresponding first database and / or second database is accessed.
2. The database access method according to claim 1, characterized in that: The performing a first route setting for the first database on the parsing result, and / or the performing a second route setting for the second database on the parsing result, includes: Performing a first time screening setting for the first database on the analysis result; and / or performing a second time screening setting for the second database on the analysis result; The first time filtering setting is used to indicate filtering of business data whose creation time is within the set time period, and the second time filtering setting is used to indicate filtering of business data whose creation time is outside the set time period.
3. The database access method according to claim 1 or 2, characterized in that: The method further comprises: According to the received adjustment request, a configuration parameter indicating the set time period is adjusted.
4. The database access method according to claim 1, characterized in that: If the analysis result includes the time screening condition, accessing the first database or accessing the second database is determined according to the time screening condition.
5. The database access method according to claim 4, characterized in that: If the analysis result does not include the time screening condition, it is determined to request access to the first database and the second database.
6. The database access method according to claim 5, characterized in that: If it is determined that the request is to access the first database and the second database, and the database access request further includes a result screening condition for limiting the access result, accessing the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting includes: accessing the first database according to the result of the first routing setting to obtain a first access result; If the first access result satisfies the result screening condition, a request response result for responding to the database access request is generated according to the first access result.
7. The database access method according to claim 6, characterized in that: The method further comprises: If the first access result does not meet the result screening condition, accessing the corresponding second database according to the result of the second routing setting to obtain a second access result; A request response result for responding to the database access request is generated according to the second access result and the first access result.
8. The database access method according to any one of claims 1 to 7, characterized in that: The second business data is the full amount of business data including the first business data; And / or, the reading and writing speed of the storage medium used by the first database is greater than the reading and writing speed of the storage medium used by the second database.
9. A database access device, characterized in that: Applied to a database system, wherein a first database and a second database are configured in the database system; include: A first determination module is configured to parse the database access request to obtain a parsing result; and determine the first database and / or the second database requested to be accessed by the database access request according to whether the parsing result contains a time screening condition for indicating a creation time of the filtered business data, wherein the first database is used to store the first business data within a set time period, and the second database is used to store the second business data; a routing setting module, configured to perform a first routing setting for the first database on the parsing result, and / or perform a second routing setting for the second database on the parsing result; the first routing setting includes setting a screening condition for the first database on the parsing result; the second routing setting includes setting a screening condition for the second database on the parsing result; An access module is used to access the corresponding first database and / or second database according to the result of the first routing setting and / or the result of the second routing setting.
10. The database access device according to claim 9, characterized in that: The routing setting module is used to perform a first time filter setting for the first database on the analysis result; and / or perform a second time filter setting for the second database on the analysis result; The first time filtering setting is used to indicate filtering of business data whose creation time is within the set time period, and the second time filtering setting is used to indicate filtering of business data whose creation time is outside the set time period.
11. The database access device according to claim 9 or 10, characterized in that: The device also includes: The adjustment module is used to adjust the configuration parameter indicating the set time period according to the received adjustment request.
12. The database access device according to claim 9, characterized in that: The first determining module comprises: A third determining module is configured to determine whether to access the first database or the second database according to the time filtering condition if the time filtering condition is included.
13. The database access device according to claim 12, characterized in that: The first determining module also includes: The fourth determining module is used to determine whether to request access to the first database and the second database if the time screening condition is not included.
14. The database access device according to claim 13, characterized in that: The access module comprises: a first routing module, configured to, when determining that a request is made to access the first database and the second database, and the database access request further includes a result screening condition limiting an access result, access the first database according to a result set by the first routing to obtain a first access result; The first generating module is configured to generate a request response result for responding to the database access request according to the first access result if the first access result satisfies the result screening condition.
15. The database access device according to claim 14, characterized in that: The access module also includes: A second routing module, configured to access a corresponding second database according to a result of the second routing setting to obtain a second access result if the first access result does not meet the result screening condition; The second generating module is used to generate a request response result for responding to the database access request according to the second access result and the first access result.
16. The database access device according to any one of claims 9 to 15, characterized in that: The second business data is the full amount of business data including the first business data; and / or the reading and writing speed of the storage medium used by the first database is greater than the reading and writing speed of the storage medium used by the second database.
17. An electronic device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the database access method according to any one of claims 1 to 8.
18. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the database access method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
Cold and hot data server system and processing method thereof
CN106156331A
Computation system, cold and hot data separation method and device and computer readable storage medium
CN108319654A