WO2020029368A1 - 数据存储方法、装置、计算机设备及存储介质 - Google Patents

数据存储方法、装置、计算机设备及存储介质 Download PDF

Info

Publication number
WO2020029368A1
WO2020029368A1 PCT/CN2018/105418 CN2018105418W WO2020029368A1 WO 2020029368 A1 WO2020029368 A1 WO 2020029368A1 CN 2018105418 W CN2018105418 W CN 2018105418W WO 2020029368 A1 WO2020029368 A1 WO 2020029368A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
database
type
correspondence
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2018/105418
Other languages
English (en)
French (fr)
Inventor
王建华
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Technology Shenzhen Co Ltd
Original Assignee
Ping An Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Technology Shenzhen Co Ltd filed Critical Ping An Technology Shenzhen Co Ltd
Publication of WO2020029368A1 publication Critical patent/WO2020029368A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Definitions

  • the present application relates to the field of database access storage, and in particular, to a data storage method, device, computer equipment, and storage medium.
  • a data storage method includes:
  • the preset status table correspondence records data status and data Table correspondence
  • the data to be stored is stored in the target data table in the target database at the write speed.
  • a data storage device includes:
  • a data acquisition module for acquiring the data type and data status of the data to be stored
  • a database correspondence module configured to select a database corresponding to the data type from each database as a target database according to a preset type library correspondence, and the type library correspondence records a correspondence relationship between the data type and the database;
  • a data table corresponding module is configured to select a data table corresponding to the data status as a target data table from each data table in the target database according to a preset status table correspondence, and the preset status table corresponds to The relationship records the correspondence between the data status and the data table;
  • a determining module configured to determine a writing speed of the target data table according to a preset speed limit rule
  • a storage module configured to store the data to be stored in the target data table in the target database at the write speed.
  • a computer device includes a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor.
  • the processor executes the computer-readable instructions, the data storage method is implemented. step.
  • One or more non-volatile readable storage media storing computer readable instructions, the computer readable storage medium storing computer readable instructions, so that the one or more processors execute the steps of the above data storage method .
  • FIG. 1 is a schematic diagram of an application environment of a data storage method according to an embodiment of the present application
  • FIG. 2 is a flowchart of a data storage method according to an embodiment of the present application.
  • FIG. 3 is a schematic flowchart of obtaining a type library correspondence in advance in an application scenario of a data storage method according to an embodiment of the present application
  • FIG. 4 is a schematic flowchart of a data storage method step S206 in an application scenario according to an embodiment of the present application;
  • FIG. 5 is a schematic flowchart of a data storage method step S103 in an application environment according to an embodiment of the present application
  • FIG. 6 is a schematic flowchart of a data access process of a data storage method in an application environment according to an embodiment of the present application
  • FIG. 7 is a schematic structural diagram of a data storage device according to an embodiment of the present application.
  • FIG. 8 is a schematic diagram of a computer device in an embodiment of the present application.
  • a data storage method provided in this application can be applied in the application environment shown in FIG. 1, in which a client communicates with a server through a network.
  • the client can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, and portable wearable devices.
  • the server can be implemented by an independent server or a server cluster composed of multiple servers.
  • a data storage method is provided.
  • the method is applied to the server in FIG. 1 as an example for description, and includes the following steps:
  • the data to be stored all have attributes of a data type and a data state, and specifically may be attributes given when the data is generated.
  • the data types may include, but are not limited to, approval, conference, document, supervision, and so on.
  • the data status can include, but is not limited to, submitted, processing, completed, archived, and so on. In particular, if necessary, the data status can also record information such as data generation time, filing time, and closing time.
  • the client requests the server to archive certain data.
  • the server can obtain the data to be archived, that is, the data to be stored. Then, the server may directly obtain its data type and data status from the data to be stored, or may request the client to provide the data type and data status of the data to be stored.
  • the server may preset a type library correspondence relationship, which records the correspondence relationship between the data type and the database. For example, suppose there are a total of 3 data types, which are approval class, meeting class, and document class; there are 3 databases, respectively database A, database B, and database C. This type library correspondence records the approval class corresponding to database A, The conference class corresponds to database B, and the document class corresponds to database C. Therefore, after the data type of the data to be stored is obtained by the server, the server can determine a corresponding database according to the corresponding relationship of the type library, and use it as the target database.
  • a type library correspondence relationship which records the correspondence relationship between the data type and the database. For example, suppose there are a total of 3 data types, which are approval class, meeting class, and document class; there are 3 databases, respectively database A, database B, and database C. This type library correspondence records the approval class corresponding to database A, The conference class corresponds to database B, and the document class corresponds to database C. Therefore, after the data type of the data to be stored
  • the correspondence between the type libraries can be obtained in advance through the following steps:
  • the server may collect historical data of each data type.
  • the historical data refers to data that belongs to a certain data type and has been stored in the database.
  • step S202 because the amount of historical data is different under different data types, some data types have more historical data and some data types have less historical data. It can be considered that for data types with more historical data, in the future There will also be more data of this type to be stored in the database, and conversely, for data types with less historical data, there will be correspondingly less data of this type to be stored in the database in the future. Therefore, by counting the data amount of the historical data under each data type, these data types can be paired with the database using the data amount as a consideration criterion in the future.
  • each data type may be sorted according to the data amount of the historical data in order, to obtain a first sequence. It can be known that the earlier the data type in the first sequence, the larger the amount of historical data; conversely, the later the data type in the first sequence, the smaller the historical data.
  • the server can learn which databases can be used to store data, and then obtain the available storage space of these databases respectively.
  • the available storage space mentioned here refers to the remaining space in the database where data can be stored. For example, if the total storage capacity of a database is 1000T and 100T has been used, the available storage space of the database is 900T.
  • each database can be sorted in order of available storage space from large to small to obtain a second sequence. It can be seen that the database that is earlier in the second sequence has larger available storage space; conversely, the database that is later in the second sequence has smaller available storage space.
  • step S206 it can be understood that when establishing the type library correspondence, consideration should be given to whether the amount of data that the database may store in the future matches the available storage space. Generally speaking, a database with a larger amount of available storage space should be allocated to a data type with a larger amount of data that may need to be stored in the future. Therefore, in this embodiment, it is possible to specifically pair each data type on the first sequence with each database on the second sequence, and establish a corresponding relationship between them to obtain the type library correspondence.
  • the data types sequentially included in the first sequence are: Type 1, Type 2, Type 3, and Type 4; the databases included in the second sequence are: Database A, Database B, Database C, and Database D.
  • the type library correspondence records are: type 1 corresponds to database A, type 2 corresponds to database B, type 3 corresponds to database C, and type 4 corresponds to database D.
  • the number of databases may be less than the number of data types. For example, there are five databases available to enterprises, but they are divided into six data types. It is necessary to distinguish the difference in quantity between the two. As shown in FIG. 4, the step S206 may specifically include:
  • each data type can be assigned to different databases one by one, so the first The top databases in the two sequences are paired one by one.
  • the data types sequentially included in the first sequence are: Type 1, Type 2, Type 3, and Type 4;
  • the databases included in the second sequence are: Database A, Database B, Database C, Database D, Database E,
  • pairing, pair Type 1, Type 2, Type 3, and Type 4 with database A, database B, database C, and database D that are in the forefront of the second sequence so that after the pairing, the type library corresponding relationship record
  • Type 1 corresponds to database A
  • Type 2 corresponds to database B
  • Type 3 corresponds to database C
  • Type 4 corresponds to database D.
  • each data type in the front row in the first sequence can be paired with each database in the second sequence, and then the unpaired data type can be paired with the last database in the second sequence.
  • the databases included in the second sequence include: database A, database B, database C, and database D .
  • first type 1, type 2, type 3, type 4 and database A, database B, database C, database D pair one by one, and then, the unmatched type 5 and last in the second sequence
  • the database D is paired, so that after the pairing, the type library correspondence records are: type 1 corresponds to database A, type 2 corresponds to database B, type 3 corresponds to database C, and type 4 and type 5 correspond to database D.
  • the server may be preset with a state table correspondence relationship, and the state table correspondence relationship records a correspondence relationship between the data state and the data table.
  • the state table correspondence relationship records a correspondence relationship between the data state and the data table. For example, suppose there are 3 data states, which are in progress, completed, and archived. There are 3 data tables in the target database, which are Table 1, Table 2, and Table 3. The corresponding relationship of the state table can record " The data in the "Processing" state is stored in Table 1, and the data in the "Completed” state is stored in Table 2. The data in the "Archived” state is stored in Table 3. Therefore, after obtaining the data status of the data to be stored, the server may determine a data table corresponding to the status table according to the corresponding relationship of the status table, and use it as the target data table.
  • the data status includes a storage time of the data to be stored.
  • the state table correspondence specifically records a one-to-one correspondence between each time interval and each data table.
  • the step S103 may specifically include:
  • S402. Determine a data table corresponding to the target time interval in each data table as a target data table according to the status table correspondence.
  • a target time interval within which the storage time falls can be directly determined. For example, suppose that there are three time intervals recorded in the corresponding relationship of the status table, which are the beginning of the month (1st to 10th), the middle of the month (11th to 20th), and the end of the month (21st to 31st). When the time is August 3, it can be determined that the data to be stored falls into the time interval of "early month", that is, the target time interval is the beginning of the month.
  • a data table corresponding to the target time interval may be determined according to the corresponding relationship of the state table, and the determined data table may be used as the target data table.
  • the data can be stored in the data table in the database and then stored in different data tables according to the storage time.
  • the query can be quickly located from the time dimension. Corresponding data tables, thereby improving the efficiency of querying data and saving database performance.
  • the server may set a limited speed rule in advance, which limits the reading speed and writing speed of each data table.
  • the writing speed of the target data table may be determined according to the speed limit rule.
  • the data to be stored may be stored in the target data table in the target database at the writing speed. It can be understood that due to the existence of speed limit rules, the performance of the target database can be well protected. When multiple write tasks are run at the same time, because the write speed of each data table is specified, even if multiple threads write more For each task, data loss or write errors are not easy to occur, which improves the stability and reliability of data storage. It also enables the database to run multiple read and write tasks at the same time, improving the data throughput efficiency of the database.
  • a data access process corresponding to the data storage may be further included.
  • the data access process may include:
  • step S501 it can be understood that during the data access process, the current data type and current data status of the data to be read are obtained, which is the same as the above step S101, and is not repeated here.
  • step S502 before reading the data, it is necessary to determine in which database the data to be read is located. Therefore, the server can query the corresponding relationship of the type library and determine the database corresponding to the current data type from each database as Access the database. It can be understood that the correspondence relationship of the type library queried by the server may be stored on the server or on the route between the server and the database, which is not specifically limited in this embodiment.
  • step S503 after determining in which database the data to be read is located (that is, the access database), it is also necessary to determine in which data table in the access database the data to be read is specific.
  • the server may The state table correspondence determines a data table corresponding to the current data state from each data table in the access database as an access data table. It can be understood that the corresponding relationship of the state table queried by the server may be stored on the server or on the route between the server and the database, which is not specifically limited in this embodiment.
  • the server may set a limited speed rule in advance, which limits the reading speed and writing speed of each data table.
  • the reading speed of the access data table may be determined according to the speed limit rule.
  • the data to be read may be read from the access data table in the access database at the reading speed.
  • the performance of the target database can be well protected.
  • the read speed of each data table is specified, even if multiple threads read multiple tasks. It is also not prone to data loss or read errors, which improves the stability and reliability of data access, and also enables the database to run multiple read and write tasks at the same time, improving the data throughput efficiency of the database.
  • the above improves a data storage method.
  • the data type and data status of the data to be stored are obtained.
  • a corresponding one of the data types is selected from each database according to the preset type library correspondence.
  • the database serves as the target database, and the type library correspondence records the correspondence between the data type and the database; then, one of the data tables in the target database is selected to correspond to the data status according to the preset state table correspondence.
  • the data table is used as the target data table, and the corresponding relationship of the status table records the corresponding relationship between the data status and the data table; after that, the writing speed of the target data table is determined according to a preset speed limit rule; finally, using the The writing speed stores the data to be stored in the target data table in the target database.
  • a data storage device for improving database access performance corresponds to the data storage method for improving database access performance in the foregoing embodiment.
  • the data storage device for improving database access performance includes a data acquisition module 601, a database correspondence module 602, a data table correspondence module 603, a determination module 604, and a storage module 605.
  • the detailed description of each function module is as follows:
  • a data acquisition module 601 configured to acquire a data type and a data state of data to be stored
  • the database correspondence module 602 is configured to select a database corresponding to the data type from each database as a target database according to a preset type library correspondence relationship, and the type library correspondence relationship records a correspondence relationship between the data type and the database;
  • a data table correspondence module 603 is configured to select a data table corresponding to the data status from each data table in the target database as a target data table according to a preset status table correspondence, and the status table correspondence records Correspondence between data status and data table;
  • a determining module 604 configured to determine a writing speed of the target data table according to a preset speed limit rule
  • the storage module 605 is configured to store the data to be stored in the target data table in the target database at the write speed.
  • a collection module for collecting historical data under each data type
  • a statistics module configured to collect, for each data type, a data amount of historical data collected under the data type
  • the data amount sorting module is configured to sort each data type according to the data amount of the historical data in descending order to obtain a first sequence
  • An acquisition module for acquiring the available storage space of each database
  • a storage space sorting module configured to sort each database in order of available storage space from large to small to obtain a second sequence
  • a pairing corresponding module is configured to pair each data type of the first sequence with each database of the second sequence to obtain a correspondence between the type libraries.
  • pairing corresponding module may include:
  • a judging unit configured to judge whether the number of each database is greater than or equal to the number of each data type
  • a corresponding unit configured to pair each data type of the first sequence with each database in the forefront of the second sequence one by one if the judgment result of the judgment unit is yes, to obtain the correspondence relationship of the type library ;
  • a pairing unit configured to pair each data type in the forefront of the first sequence with each database of the second sequence if the judgment result of the judgment unit is negative, and then match the unpaired data types And pairing with the last database in the second sequence to obtain the type library correspondence.
  • the data table corresponding module may include:
  • a time interval determining module configured to determine a target time interval during which the storage time of the data to be stored falls
  • the target data table correspondence module is configured to determine a data table corresponding to the target time interval in each of the data tables as a target data table according to the state table correspondence.
  • the data storage device may further include:
  • Get data type status module used to get the current data type and current data status of the data to be read
  • An access database determination module configured to determine a database corresponding to the current data type from each database as an access database according to the type library correspondence;
  • An access data table determining module configured to determine a data table corresponding to the current data status as an access data table from each data table in the access database according to the preset state table correspondence;
  • a reading speed determining module configured to determine a reading speed of the access data table according to the preset speed limit rule
  • a data reading module is configured to read the data to be read from the access data table in the access database at the reading speed.
  • Each module in the data storage device for improving database access performance may be implemented in whole or in part by software, hardware, and a combination thereof.
  • the above-mentioned modules may be embedded in the hardware form or independent of the processor in the computer device, or may be stored in the memory of the computer device in the form of software, so that the processor calls and performs the operations corresponding to the above modules.
  • a computer device is provided.
  • the computer device may be a server, and its internal structure diagram may be as shown in FIG. 8.
  • the computer device includes a processor, a memory, a network interface, and a database connected through a system bus.
  • the processor of the computer device is used to provide computing and control capabilities.
  • the memory of the computer device includes a non-volatile storage medium and an internal memory.
  • the non-volatile storage medium stores an operating system, computer-readable instructions, and a database.
  • the internal memory provides an environment for operating the operating system and computer-readable instructions in a non-volatile storage medium.
  • the database of the computer equipment is used to store data involved in the data storage method.
  • the network interface of the computer device is used to communicate with an external terminal through a network connection.
  • the computer-readable instructions are executed by a processor to implement a data storage method.
  • a computer device including a memory, a processor, and computer-readable instructions stored on the memory and executable on the processor.
  • the processor executes the computer-readable instructions
  • the data in the foregoing embodiment is implemented.
  • the steps of the storage method are, for example, steps S101 to S105 shown in FIG. 2.
  • the processor executes the computer-readable instructions
  • the functions of the modules / units of the device in the foregoing embodiments are implemented, for example, the functions of modules 601 to 605 shown in FIG. 7. To avoid repetition, we will not repeat them here.
  • a computer-readable storage medium is provided, the one or more non-volatile storage mediums storing computer-readable instructions, and the computer-readable instructions are executed by one or more processors.
  • the computer When the readable instruction is executed by one or more processors, when the one or more processors execute the computer-readable instructions, the functions of each module / unit in the data storage device in the foregoing device embodiments are implemented. To avoid repetition, we will not repeat them here.
  • Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory.
  • Volatile memory can include random access memory (RAM) or external cache memory.
  • RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
  • SRAM static RAM
  • DRAM dynamic RAM
  • SDRAM synchronous DRAM
  • DDRSDRAM dual data rate SDRAM
  • ESDRAM enhanced SDRAM
  • SLDRAM synchronous chain Synchlink DRAM
  • Rambus direct RAM
  • DRAM direct memory bus dynamic RAM
  • RDRAM memory bus dynamic RAM

Landscapes

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

Abstract

一种数据存储方法、数据存储装置、计算机设备及存储介质,用于解决现有数据库查询数据效率低下的问题。所述方法包括:获取待存储数据的数据类型和数据状态(S101);根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系(S102);根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述状态表对应关系记录了数据状态与数据表的对应关系(S103);根据预设的限速规则确定所述目标数据表的写入速度(S104);以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中(S105)。

Description

数据存储方法、装置、计算机设备及存储介质
本申请以2018年08月10日提交的申请号为201810905702.2,名称为“数据存储方法、装置、计算机设备及存储介质”的中国发明专利申请为基础,并要求其优先权。
技术领域
本申请涉及数据库访问存储领域,尤其涉及到一种数据存储方法、装置、计算机设备及存储介质。
背景技术
进入大数据时代后,企业需要存储记录的数据量激增,容易导致一个数据库中存储、堆积有巨量的数据信息。当需要查询某个数据时,往往需要遍历该数据库中的数据才能得到查询结果,这不仅对数据库的性能要求极高,而且使得查询数据的效率低下。
因此,寻找一种有利于提高数据库访问性能的数据存储方法成为本领域技术人员亟需解决的问题。
发明内容
基于此,有必要针对上述技术问题,提供一种可以提高数据库访问性能的数据存储方法、装置、计算机设备及存储介质。
一种数据存储方法,包括:
获取待存储数据的数据类型和数据状态;
根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
根据预设的限速规则确定所述目标数据表的写入速度;
以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
一种数据存储装置,包括:
数据获取模块,用于获取待存储数据的数据类型和数据状态;
数据库对应模块,用于根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
数据表对应模块,用于根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
确定模块,用于根据预设的限速规则确定所述目标数据表的写入速度;
存储模块,用于以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现上述数据存储方法的步骤。
一个或多个存储有计算机可读指令的非易失性可读存储介质,所述计算机可读存储介质存储有计算机可读指令,使得所述一个或多个处理器执行上述数据存储方法的步骤。
本申请的一个或多个实施例的细节在下面的附图和描述中提出,本申请的其他特征和优点将从说明书、附图以及权利要求变得明显。
附图说明
为了更清楚地说明本申请实施例的技术方案,下面将对本申请实施例的描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1是本申请一实施例中数据存储方法的一应用环境示意图;
图2是本申请一实施例中数据存储方法的一流程图;
图3是本申请一实施例中数据存储方法在一个应用场景下预先得到类型库对应关系的流程示意图;
图4是本申请一实施例中数据存储方法步骤S206在一个应用场景下的流程示意图;
图5是本申请一实施例中数据存储方法步骤S103在一个应用环境下的流程示意图;
图6是本申请一实施例中数据存储方法在一个应用环境下数据访问过程的流程示意图;
图7是本申请一实施例中数据存储装置的结构示意图;
图8是本申请一实施例中计算机设备的一示意图。
具体实施方式
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
本申请提供的一种数据存储方法,可应用在如图1的应用环境中,其中,客户端通过网络与服务器进行通信。其中,客户端可以但不限于各种个人计算机、笔记本电脑、智能手机、平板电脑和便携式可穿戴设备。服务器可以用独立的服务器或者是多个服务器组成的服务器集群来实现。
在一实施例中,如图2所示,提供一种数据存储方法,以该方法应用在图1中的服务器为例进行说明,包括如下步骤:
S101、获取待存储数据的数据类型和数据状态;
本实施例中,这些待存储数据均具有数据类型、数据状态的属性,具体可以是在生成数据时就赋予的属性。其中,数据类型可以包括但不限于审批类、会议类、公文类、督办类,等等。数据状态可以包括但不限于已提交、处理中、已完结、已归档,等等。特别地,在必要是,数据状态还可以记录数据的生成时间、归档时间、办结时间等信息。
在某个应用场景中,客户端向服务器请求将某数据归档,服务器接收到该请求后,可以获取到要归档的数据,即上述的待存储数据。然后,服务器可以从该待存储数据中直接获取到其数据类型和数据状态,也可以要求该客户端提供该待存储数据的数据类型和数据状态。
S102、根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
本实施例中,服务器可以预先设置有类型库对应关系,该类型库对应关系记录了数据类型与数据库的对应关系。比如,设共有3个数据类型,分别为审批类、会议类、公文类;共有3个数据库,分别为数据库A、数据库B和数据库C,该类型库对应关系记录了审批 类与数据库A对应、会议类与数据库B对应、公文类与数据库C对应。从而,服务器在获取到待存储数据的数据类型后,可以依据该类型库对应关系确定与之对应的数据库,将其作为目标数据库。
进一步地,如图3所示,所述类型库对应关系可以通过以下步骤预先得到:
S201、分别收集各个数据类型下的历史数据;
S202、针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据量;
S203、按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
S204、分别获取各个数据库的可用存储空间;
S205、按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
S206、将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
对于步骤S201,可以理解的是,服务器在建立类型库对应关系之前,可以先收集每种数据类型的历史数据,这些历史数据是指属于某个数据类型的、曾经存储过至数据库中的数据。
对于步骤S202,由于不同数据类型下的历史数据的数据量不相同,有些数据类型的历史数据较多,有些数据类型的历史数据则较少,可以认为,对于历史数据较多的数据类型,将来要存储至数据库中的该类型的数据也会更多,反之,对于历史数据较少的数据类型,将来要存储至数据库中的该类型的数据也相应更少些。因此,通过统计每个数据类型下的历史数据的数据量,后续可以以数据量作为考量标准来配对这些数据类型和数据库。
对于步骤S203,在统计得到各个数据类型下历史数据的数据量后,可以按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列。可知,在第一序列中越靠前的数据类型,其历史数据的数据量越大;反之,在第一序列中越靠后的数据类型,其历史数据的数据量越小。
对于步骤S204,在建立类型库对应关系之前,服务器可以获知到哪些数据库是可以被用于存储数据的,然后分别获取这些数据库的可用存储空间。这里说的可用存储空间是指数据库的剩余可以存储数据的空间。比如某个数据库总存量为1000T,已使用100T,则该数据库的可用存储空间为900T。
对于步骤S205,在分别获取各个数据库的可用存储空间之后,可以按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列。可知,在第二序列中越靠前的数 据库,其可用存储空间越大;反之,在第二序列中越靠后的数据库,其可用存储空间越小。
对于步骤S206,可以理解的是,在建立类型库对应关系时,应当考虑到数据库将来可能存储的数据量与可用存储空间两者是否匹配。一般来说,可用存储空间越大的数据库应当分配给将来可能需要存储的数据量越大的数据类型。因此,本实施例中,具体可以将第一序列上的各个数据类型与第二序列上的各个数据库一一对应配对,建立两者对应关系,即得到该类型库对应关系。例如,第一序列中依次包括的数据类型有:类型1、类型2、类型3、类型4;第二序列中依次包括的数据库有:数据库A、数据库B、数据库C、数据库D,则配对后,该类型库对应关系记录有:类型1与数据库A对应、类型2与数据库B对应、类型3与数据库C对应、类型4与数据库D对应。
更进一步地,考虑到在某些情况下,数据库的数量可能会少于数据类型的数量,比如企业可用的数据库为5个,但划分为6个数据类型出来,此时建立类型库对应关系时需要区分两者数量上的区别,如图4所示,所述步骤S206具体可以包括:
S301、判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量,若是,则执行步骤S302,若否,则执行步骤S303;
S302、将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
S303、将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
对于步骤S301-S303,可以理解的是,当所述各个数据库的数量大于或等于所述各个数据类型的数量时,所述各个数据类型是可以一一分配给不同的数据库的,因此可以选取第二序列中位于前列的数据库进行一一配对。例如,第一序列中依次包括的数据类型有:类型1、类型2、类型3、类型4;第二序列中依次包括的数据库有:数据库A、数据库B、数据库C、数据库D、数据库E,则配对时,将类型1、类型2、类型3、类型4与位于第二序列中前列的数据库A、数据库B、数据库C、数据库D进行一一配对,从而配对后,该类型库对应关系记录有:类型1与数据库A对应、类型2与数据库B对应、类型3与数据库C对应、类型4与数据库D对应。
当所述各个数据库的数量小于所述各个数据类型的数量时,可知,所述各个数据类型是无法一一分配给不同的数据库的,总得有两个以上的数据类型共用同一个数据库。因此,可以先将第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然 后再将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对。例如,设第一序列中依次包括的数据类型有:类型1、类型2、类型3、类型4、类型5;第二序列中依次包括的数据库有:数据库A、数据库B、数据库C、数据库D,则配对时,先将类型1、类型2、类型3、类型4与数据库A、数据库B、数据库C、数据库D进行一一配对,然后,将还未配对的类型5与位于第二序列最后的数据库D配对,从而配对后,该类型库对应关系记录有:类型1与数据库A对应、类型2与数据库B对应、类型3与数据库C对应、类型4和类型5与数据库D对应。
S103、根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述状态表对应关系记录了数据状态与数据表的对应关系;
本实施例中,服务器可以预先设置有状态表对应关系,该状态表对应关系记录了数据状态与数据表的对应关系。比如,设共有3个数据状态,分别为处理中、已完结、已归档;该目标数据库内共有3个数据表,分别为表1、表2和表3,则该状态表对应关系可以记录“处理中”状态的数据存储至表1、“已完结”状态的数据存储至表2、“已归档”状态的数据存储至表3。从而,服务器在获取到待存储数据的数据状态后,可以根据该状态表对应关系确定与之对应的数据表,将其作为目标数据表。
进一步地,所述数据状态包括所述待存储数据的存储时间。本实施例中,在将数据存储至数据库时,可以依据存档时间(即存储数据的时间)将不同的数据划分至不同的数据表中,以便于后续查询、访问数据时可以从时间维度上检索数据。因此,所述状态表对应关系具体记录了各个时间区间与各个数据表的一一对应关系,如图5所示,所述步骤S103具体可以包括:
S401、确定所述待存储数据的存储时间落入的目标时间区间;
S402、根据所述状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
对于步骤S401,在获取到该待存储数据的存储时间之后,可以直接确定出该存储时间落入的目标时间区间。比如,设该状态表对应关系中记录了3个时间区间,分别为月初(1号至10号)、月中(11号至20号)和月尾(21号至31号),若该存储时间为8月3日,则可以确定该待存储数据落入“月初”这一时间区间,即目标时间区间为月初。
对于步骤S402,在确定出目标时间区间之后,根据状态表对应关系可以确定出与该目标时间区间对应的数据表,将确定出的数据表作为该目标数据表即可。
由上述内容可知,通过上述步骤S401和S402,可以使得数据存储至数据库中的数据表后,根据存储时间的不同存储在不同的数据表中,在查询数据时,可以从时间维度上快速定位查询对应的数据表,从而提高查询数据的效率,节省数据库的性能。
S104、根据预设的限速规则确定所述目标数据表的写入速度;
本实施例中,服务器可以预先设置有限速规则,该限速规则限定了各个数据表的读取速度和写入速度。这里,由于仅需存储数据,因此根据该限速规则确定出该目标数据表的写入速度即可。
S105、以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
在确定出所述写入速度之后,可以以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。可以理解的是,由于限速规则的存在,可以很好地保护目标数据库的性能,当同时运行多个写入任务时,由于规定好了各个数据表的写入速度,即便多线程写入多个任务,也不容易出现数据丢失或写入错误的情况,提高了数据存储的稳定性、可靠性,也使得数据库在使用时可以同时运行多个读写任务,提升数据库的数据吞吐效率。
进一步地,如图6所示,在将所述待存储数据存储至所述目标数据库内的所述目标数据表中之后,还可以包括与数据存储对应的数据访问过程。具体地,数据访问的过程可以包括:
S501、获取待读取数据的当前数据类型和当前数据状态;
S502、根据所述类型库对应关系从各个数据库中确定出与所述当前数据类型对应的数据库作为访问数据库;
S503、根据所述状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
S504、根据所述限速规则确定所述访问数据表的读取速度;
S505、以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
对于步骤S501,可以理解的是,在数据访问的过程中,获取该待读取数据的当前数据类型和当前数据状态,其与上述步骤S101同理,此处不再赘述。
对于步骤S502,在读取数据之前,需要先确定该待读取数据位于哪个数据库中,因此,服务器可以查询该类型库对应关系,从各个数据库中确定出与所述当前数据类型对 应的数据库作为访问数据库。可以理解的是,服务器查询的该类型库对应关系可以存放在服务器上,也可以存放在服务器与数据库之间的路由上,对此本实施例不作具体限定。
对于步骤S503,在确定出该待读取数据在哪个数据库(即该访问数据库)后,还需要确定该待读取数据具体在访问数据库中的哪个数据表中,对此,服务器可以根据所述状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表。可以理解的是,服务器查询的该状态表对应关系可以存放在服务器上,也可以存放在服务器与数据库之间的路由上,对此本实施例不作具体限定。
对于步骤S504,与上述步骤S104同理,服务器可以预先设置有限速规则,该限速规则限定了各个数据表的读取速度和写入速度。这里,由于仅需读取数据,因此根据该限速规则确定出该访问数据表的读取速度即可。
对于步骤S505,在确定出该访问数据表要求的读取速度之后,可以以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。同理,由于限速规则的存在,可以很好地保护目标数据库的性能,当同时运行多个读取任务时,由于规定好了各个数据表的读取速度,即便多线程读取多个任务,也不容易出现数据丢失或读取错误的情况,提高了数据访问的稳定性、可靠性,也使得数据库在使用时可以同时运行多个读写任务,提升数据库的数据吞吐效率。
综上所示,上述提高了一种数据存储方法,首先,获取待存储数据的数据类型和数据状态;然后,根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;接着,根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述状态表对应关系记录了数据状态与数据表的对应关系;之后,根据预设的限速规则确定所述目标数据表的写入速度;最后,以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。这样,通过依据数据类型和数据状态将待存储的数据划分中不同的数据库以及不同的数据表中,可以实现数据的分离存储,避免了大量数据堆积在同一数据库或者同一数据表中导致数据查询效率低下的问题,有利于提高数据库访问性能。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
在一实施例中,提供一种提高数据库访问性能的数据存储的装置,该提高数据库访问 性能的数据存储的装置与上述实施例中提高数据库访问性能的数据存储的方法一一对应。如图7所示,该提高数据库访问性能的数据存储的装置包括数据获取模块601、数据库对应模块602、数据表对应模块603、确定模块604和存储模块605。各功能模块详细说明如下:
数据获取模块601,用于获取待存储数据的数据类型和数据状态;
数据库对应模块602,用于根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
数据表对应模块603,用于根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述状态表对应关系记录了数据状态与数据表的对应关系;
确定模块604,用于根据预设的限速规则确定所述目标数据表的写入速度;
存储模块605,用于以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
进一步地,所述类型库对应关系可以通过以下模块预先得到:
收集模块,用于分别收集各个数据类型下的历史数据;
统计模块,用于针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据量;
数据量排序模块,用于按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
获取模块,用于分别获取各个数据库的可用存储空间;
存储空间排序模块,用于按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
配对对应模块,用于将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
进一步地,所述配对对应模块可以包括:
判断单元,用于判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量;
对应单元,用于若所述判断单位的判断结果为是,则将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
配对单元,用于若所述判断单位的判断结果为否,则将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
进一步地,所述数据表对应模块可以包括:
时间区间确定模块,用于确定所述待存储数据的存储时间落入的目标时间区间;
目标数据表对应模块,用于根据所述状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
进一步地,所述数据存储装置还可以包括:
获取数据类型状态模块,用于获取待读取数据的当前数据类型和当前数据状态;
访问数据库确定模块,用于根据所述类型库对应关系从各个数据库中确定出与所述的当前数据类型对应的数据库作为访问数据库;
访问数据表确定模块,用于根据所述预设的状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
读取速度确定模块,用于根据所述预设的限速规则确定所述访问数据表的读取速度;
数据读取模块,用于以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
关于数据存储装置的具体限定可以参见上文中对于数据存储方法的限定,在此不再赘述。上述提高数据库访问性能的数据存储装置中的各个模块可全部或部分通过软件、硬件及其组合来实现。上述各模块可以硬件形式内嵌于或独立于计算机设备中的处理器中,也可以以软件形式存储于计算机设备中的存储器中,以便于处理器调用执行以上各个模块对应的操作。
在一个实施例中,提供了一种计算机设备,该计算机设备可以是服务器,其内部结构图可以如图8所示。该计算机设备包括通过系统总线连接的处理器、存储器、网络接口和数据库。其中,该计算机设备的处理器用于提供计算和控制能力。该计算机设备的存储器包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统、计算机可读指令和数据库。该内存储器为非易失性存储介质中的操作系统和计算机可读指令的运行提供环境。该计算机设备的数据库用于存储数据存储方法中涉及到的数据。该计算机设备的网络接口用于与外部的终端通过网络连接通信。该计算机可读指令被处理器执行时以实现一种数据存储方法。
在一个实施例中,提供了一种计算机设备,包括存储器、处理器及存储在存储器上并可在处理器上运行的计算机可读指令,处理器执行计算机可读指令时实现上述实施例中数据存储方法的步骤,例如图2所示的步骤S101至步骤S105。或者,处理器执行计算机可读指令时实现上述实施例中装置的各模块/单元的功能,例如图7所示模块601至模块605的功能。为避免重复,这里不再赘述。
在一个实施例中,提供了一种计算机可读存储介质,该一个或多个存储有计算机可读指令的非易失性可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或 多个处理器执行计算机可读指令时实现上述方法实施例中数据存储方法的步骤,或者,该一个或多个存储有计算机可读指令的非易失性可读存储介质,计算机可读指令被一个或多个处理器执行时,使得一个或多个处理器执行计算机可读指令时实现上述装置实施例中数据存储装置中各模块/单元的功能。为避免重复,这里不再赘述。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机可读指令来指令相关的硬件来完成,所述的计算机可读指令可存储于一非易失性计算机可读取存储介质中,该计算机可读指令在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。
以上所述实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围,均应包含在本申请的保护范围之内。

Claims (20)

  1. 一种数据存储方法,其特征在于,包括:
    获取待存储数据的数据类型和数据状态;
    根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
    根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
    根据预设的限速规则确定所述目标数据表的写入速度;
    以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
  2. 根据权利要求1所述的数据存储方法,其特征在于,所述类型库对应关系通过以下步骤预先得到:
    分别收集各个数据类型下的历史数据;
    针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据量;
    按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
    分别获取各个数据库的可用存储空间;
    按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
    将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
  3. 根据权利要求2所述的数据存储方法,其特征在于,所述将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系具体包括:
    判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量;
    若所述各个数据库的数量大于或等于所述各个数据类型的数量,则将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
    若所述各个数据库的数量小于所述各个数据类型的数量,则将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
  4. 根据权利要求1所述的数据存储方法,其特征在于,所述数据状态包括所述待存储 数据的存储时间,所述预设的状态表对应关系记录了各个时间区间与各个数据表的一一对应关系;所述根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表具体包括:
    确定所述待存储数据的存储时间落入的目标时间区间;
    根据所述预设的状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
  5. 根据权利要求1至4中任一项所述的数据存储方法,其特征在于,在将所述待存储数据存储至所述目标数据库内的所述目标数据表中之后,还包括:
    获取待读取数据的当前数据类型和当前数据状态;
    根据所述类型库对应关系从各个数据库中确定出与所述当前数据类型对应的数据库作为访问数据库;
    根据所述预设的状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
    根据所述预设的限速规则确定所述访问数据表的读取速度;
    以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
  6. 一种数据存储装置,其特征在于,包括:
    数据获取模块,用于获取待存储数据的数据类型和数据状态;
    数据库对应模块,用于根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
    数据表对应模块,用于根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
    确定模块,用于根据预设的限速规则确定所述目标数据表的写入速度;
    存储模块,用于以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
  7. 根据权利要求6所述的数据存储装置,其特征在于,所述类型库对应关系通过以下模块预先得到:
    收集模块,用于分别收集各个数据类型下的历史数据;
    统计模块,用于针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据 量;
    数据量排序模块,用于按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
    获取模块,用于分别获取各个数据库的可用存储空间;
    存储空间排序模块,用于按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
    配对对应模块,用于将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
  8. 根据权利要求7所述的数据存储装置,其特征在于,所述配对对应模块包括:
    判断单元,用于判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量;
    对应单元,用于若所述判断单位的判断结果为是,则将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
    配对单元,用于若所述判断单位的判断结果为否,则将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
  9. 根据权利要求6所述的数据存储装置,其特征在于,所述数据表对应模块包括:
    时间区间确定模块,用于确定所述待存储数据的存储时间落入的目标时间区间;
    目标数据表对应模块,用于根据所述状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
  10. 根据权利要求6至9中任一项所述的数据存储装置,其特征在于,所述数据存储装置还包括:
    获取数据类型状态模块,用于获取待读取数据的当前数据类型和当前数据状态;
    访问数据库确定模块,用于根据所述类型库对应关系从各个数据库中确定出与所述的当前数据类型对应的数据库作为访问数据库;
    访问数据表确定模块,用于根据所述预设的状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
    读取速度确定模块,用于根据所述预设的限速规则确定所述访问数据表的读取速度;
    数据读取模块,用于以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
  11. 一种计算机设备,包括存储器、处理器以及存储在所述存储器中并可在所述处理器上运行的计算机可读指令,其特征在于,所述处理器执行所述计算机可读指令时实现如下步骤:
    获取待存储数据的数据类型和数据状态;
    根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
    根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
    根据预设的限速规则确定所述目标数据表的写入速度;
    以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
  12. 根据权利要求11所述的计算机设备,其特征在于,所述类型库对应关系通过以下步骤预先得到:
    分别收集各个数据类型下的历史数据;
    针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据量;
    按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
    分别获取各个数据库的可用存储空间;
    按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
    将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
  13. 根据权利要求12所述的计算机设备,其特征在于,所述将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系具体包括:
    判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量;
    若所述各个数据库的数量大于或等于所述各个数据类型的数量,则将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
    若所述各个数据库的数量小于所述各个数据类型的数量,则将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
  14. 根据权利要求11所述的计算机设备,其特征在于,所述数据状态包括所述待存储 数据的存储时间,所述预设的状态表对应关系记录了各个时间区间与各个数据表的一一对应关系;所述根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表具体包括:
    确定所述待存储数据的存储时间落入的目标时间区间;
    根据所述预设的状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
  15. 根据权利要求11至14中任一项所述的计算机设备,其特征在于,在将所述待存储数据存储至所述目标数据库内的所述目标数据表中之后,所述处理器执行所述计算机可读指令时还实现如下步骤:
    获取待读取数据的当前数据类型和当前数据状态;
    根据所述类型库对应关系从各个数据库中确定出与所述当前数据类型对应的数据库作为访问数据库;
    根据所述预设的状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
    根据所述预设的限速规则确定所述访问数据表的读取速度;
    以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
  16. 一个或多个存储有计算机可读指令的非易失性可读存储介质,其特征在于,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器执行如下步骤:
    获取待存储数据的数据类型和数据状态;
    根据预设的类型库对应关系从各个数据库中选取一个与所述数据类型对应的数据库作为目标数据库,所述类型库对应关系记录了数据类型与数据库的对应关系;
    根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表,所述预设的状态表对应关系记录了数据状态与数据表的对应关系;
    根据预设的限速规则确定所述目标数据表的写入速度;
    以所述写入速度将所述待存储数据存储至所述目标数据库内的所述目标数据表中。
  17. 根据权利要求16所述的非易失性可读存储介质,其特征在于,所述类型库对应关系通过以下步骤预先得到:
    分别收集各个数据类型下的历史数据;
    针对每个数据类型,统计收集到的所述数据类型下的历史数据的数据量;
    按照历史数据的数据量从大到小的顺序对各个数据类型进行排序,得到第一序列;
    分别获取各个数据库的可用存储空间;
    按照可用存储空间从大到小的顺序对各个数据库进行排序,得到第二序列;
    将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系。
  18. 根据权利要求17所述的非易失性可读存储介质,其特征在于,所述将所述第一序列的各个数据类型与所述第二序列的各个数据库进行配对,得到所述类型库对应关系具体包括:
    判断所述各个数据库的数量是否大于或等于所述各个数据类型的数量;
    若所述各个数据库的数量大于或等于所述各个数据类型的数量,则将所述第一序列的各个数据类型与所述第二序列中位于前列的各个数据库一一配对,得到所述类型库对应关系;
    若所述各个数据库的数量小于所述各个数据类型的数量,则将所述第一序列中位于前列的各个数据类型与所述第二序列的各个数据库一一配对,然后将未配对的数据类型与所述第二序列中排列最后的一个数据库进行配对,得到所述类型库对应关系。
  19. 根据权利要求16所述的非易失性可读存储介质,其特征在于,所述数据状态包括所述待存储数据的存储时间,所述预设的状态表对应关系记录了各个时间区间与各个数据表的一一对应关系;所述根据预设的状态表对应关系从所述目标数据库内的各个数据表中选取一个与所述数据状态对应的数据表作为目标数据表具体包括:
    确定所述待存储数据的存储时间落入的目标时间区间;
    根据所述预设的状态表对应关系确定所述各个数据表中与所述目标时间区间对应的数据表作为目标数据表。
  20. 根据权利要求16至19中任一项所述的非易失性可读存储介质,其特征在于,在将所述待存储数据存储至所述目标数据库内的所述目标数据表中之后,所述计算机可读指令被一个或多个处理器执行时,使得所述一个或多个处理器还执行如下步骤:
    获取待读取数据的当前数据类型和当前数据状态;
    根据所述类型库对应关系从各个数据库中确定出与所述当前数据类型对应的数据库作为访问数据库;
    根据所述预设的状态表对应关系从所述访问数据库内的各个数据表中确定出与所述当前数据状态对应的数据表作为访问数据表;
    根据所述预设的限速规则确定所述访问数据表的读取速度;
    以所述读取速度从所述访问数据库内的所述访问数据表中读取出所述待读取数据。
PCT/CN2018/105418 2018-08-10 2018-09-13 数据存储方法、装置、计算机设备及存储介质 Ceased WO2020029368A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810905702.2A CN109189785A (zh) 2018-08-10 2018-08-10 数据存储方法、装置、计算机设备及存储介质
CN201810905702.2 2018-08-10

Publications (1)

Publication Number Publication Date
WO2020029368A1 true WO2020029368A1 (zh) 2020-02-13

Family

ID=64921404

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/105418 Ceased WO2020029368A1 (zh) 2018-08-10 2018-09-13 数据存储方法、装置、计算机设备及存储介质

Country Status (2)

Country Link
CN (1) CN109189785A (zh)
WO (1) WO2020029368A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401250A (zh) * 2023-03-28 2023-07-07 杭州数梦工场科技有限公司 一种web数据存储方法及装置

Families Citing this family (23)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109871416A (zh) * 2019-02-28 2019-06-11 上海汽车集团股份有限公司 数据储存方法、装置以及计算机存储介质
CN110502540A (zh) * 2019-07-23 2019-11-26 招联消费金融有限公司 数据处理方法、装置、计算机设备和存储介质
CN112835967B (zh) * 2019-11-25 2023-07-21 浙江宇视科技有限公司 基于分布式存储系统的数据处理方法、装置、设备和介质
CN110955704A (zh) * 2019-12-03 2020-04-03 北京锐安科技有限公司 一种数据管理方法、装置、设备及存储介质
CN110968647A (zh) * 2019-12-23 2020-04-07 广东电力交易中心有限责任公司 数据存储方法、装置、计算机设备和存储介质
CN111221824B (zh) * 2020-01-02 2023-05-26 广州虎牙科技有限公司 存储空间的存储优化方法、装置、设备和介质
CN111291119B (zh) * 2020-01-21 2023-04-25 郑州阿帕斯数云信息科技有限公司 数据同步方法和装置
CN111475517B (zh) * 2020-03-06 2024-02-20 平安科技(深圳)有限公司 数据更新方法、装置、计算机设备及存储介质
CN111831232A (zh) * 2020-07-22 2020-10-27 浙江大华技术股份有限公司 数据的存储方法及装置、存储介质和电子装置
CN112001160B (zh) * 2020-08-27 2023-07-28 中国平安财产保险股份有限公司 数据处理方法、装置、设备及存储介质
CN111782640B (zh) * 2020-09-04 2021-02-19 苏州浪潮智能科技有限公司 一种云平台的数据处理方法、系统、电子设备及存储介质
CN113760889B (zh) * 2020-11-09 2024-05-17 北京沃东天骏信息技术有限公司 数据处理方法、装置、计算机系统和计算机可读存储介质
CN112328688B (zh) * 2020-11-09 2023-10-13 广州虎牙科技有限公司 数据存储方法、装置、计算机设备及存储介质
CN112364007B (zh) * 2020-11-18 2023-08-22 中国平安人寿保险股份有限公司 基于数据库的海量数据交换方法、装置、设备和存储介质
CN112434189A (zh) * 2020-12-02 2021-03-02 新华三大数据技术有限公司 数据查询方法、装置及设备
CN114595219A (zh) * 2020-12-04 2022-06-07 中国移动通信集团广东有限公司 一种数据存储方法、装置和系统
CN112632080B (zh) * 2020-12-29 2023-01-13 杭州趣链科技有限公司 基于区块链的数据存储方法、装置及设备
CN113392159A (zh) * 2021-06-18 2021-09-14 湖南快乐阳光互动娱乐传媒有限公司 一种数据共享方法及装置
CN113721518A (zh) * 2021-08-31 2021-11-30 中冶华天南京工程技术有限公司 一种面向钢铁生产的数据采集和存储方法
CN114822804B (zh) * 2022-06-30 2022-09-20 深圳核心医疗科技有限公司 数据存储方法、装置、计算机设备和存储介质
CN115203257A (zh) * 2022-07-12 2022-10-18 广州欢聚时代信息科技有限公司 数据流生成方法及其装置、设备、介质、产品
CN116894045A (zh) * 2023-07-24 2023-10-17 广州商研网络科技有限公司 网络提取数据存储方法及其装置、设备、介质
CN119760784B (zh) * 2025-03-05 2025-06-13 北京捷科智诚科技有限公司 一种一体化测试服务平台的数据隔离方法及平台

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779186A (zh) * 2012-06-29 2012-11-14 浙江大学 一种非结构化数据管理的全过程建模方法
CN104516894A (zh) * 2013-09-27 2015-04-15 国际商业机器公司 用于管理时间序列数据库的方法和装置
US20150278233A1 (en) * 2014-03-25 2015-10-01 Yokogawa Electric Corporation Data storage management apparatus and data storage management method
CN108023957A (zh) * 2017-12-07 2018-05-11 温州中壹技术服务有限公司 一种用于信息快速采集处理的互助式计算机网络管理系统
CN108108384A (zh) * 2016-11-25 2018-06-01 中国移动通信有限公司研究院 一种数据存储方法及装置

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20100094838A1 (en) * 2008-10-10 2010-04-15 Ants Software Inc. Compatibility Server for Database Rehosting
US10055442B2 (en) * 2014-10-31 2018-08-21 Microsoft Technology Licensing, Llc Efficient updates in non-clustered column stores
CN107967284B (zh) * 2016-10-20 2022-07-05 北京京东尚科信息技术有限公司 用于存储、查询订单信息的方法和装置
CN108052281A (zh) * 2017-11-30 2018-05-18 平安科技(深圳)有限公司 业务资料存储方法、应用服务器及计算机存储介质

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102779186A (zh) * 2012-06-29 2012-11-14 浙江大学 一种非结构化数据管理的全过程建模方法
CN104516894A (zh) * 2013-09-27 2015-04-15 国际商业机器公司 用于管理时间序列数据库的方法和装置
US20150278233A1 (en) * 2014-03-25 2015-10-01 Yokogawa Electric Corporation Data storage management apparatus and data storage management method
CN108108384A (zh) * 2016-11-25 2018-06-01 中国移动通信有限公司研究院 一种数据存储方法及装置
CN108023957A (zh) * 2017-12-07 2018-05-11 温州中壹技术服务有限公司 一种用于信息快速采集处理的互助式计算机网络管理系统

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401250A (zh) * 2023-03-28 2023-07-07 杭州数梦工场科技有限公司 一种web数据存储方法及装置

Also Published As

Publication number Publication date
CN109189785A (zh) 2019-01-11

Similar Documents

Publication Publication Date Title
WO2020029368A1 (zh) 数据存储方法、装置、计算机设备及存储介质
CN102725753B (zh) 优化数据访问的方法及装置、优化数据存储的方法及装置
US10210196B2 (en) Data storage device having internal hardware filter, data storage method and data storage system
WO2021031687A1 (zh) 数据库分库分表的分页查询方法、装置和计算机设备
CN112287182A (zh) 图数据存储、处理方法、装置及计算机存储介质
US10120588B2 (en) Sliding-window multi-class striping
CN105468642A (zh) 数据的存储方法及装置
US12306746B2 (en) Method and apparatus for updating RAID 5 check value, and medium
US20200257732A1 (en) Systems and methods of managing an index
US20150193491A1 (en) Data indexing method and apparatus
TW201415262A (zh) 基於Lucene的倒排索引系統構建、資料處理方法及裝置
WO2017041570A1 (zh) 向缓存写入数据的方法及装置
WO2020232880A1 (zh) 数据处理方法、装置、存储介质及终端设备
CN109947738A (zh) 数据转移系统及方法
CN111625600A (zh) 数据存储的处理方法、系统、计算机设备及存储介质
CN119847739A (zh) 基于动态分片的数据库负载优化方法、装置、设备及介质
CN105677903A (zh) 获取数据的方法和装置、计算机设备
CN117785952A (zh) 一种数据查询方法、装置、服务器及介质
CN111260253A (zh) 信息发送方法、装置、计算机设备及存储介质
CN120804104A (zh) 混合内存索引管理方法、装置、设备及介质
CN115563109A (zh) 一种LSM-tree存储的L0层数据处理方法及装置
CN110245130A (zh) 数据去重方法、装置、计算机设备及存储介质
CN111651466B (zh) 数据采样方法及装置
CN110765125A (zh) 一种存储数据的方法及装置
CN111813761A (zh) 一种数据库管理方法、装置以及计算机存储介质

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: 18929184

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: 18929184

Country of ref document: EP

Kind code of ref document: A1