[go: up one dir, main page]

CN106919617B - Compression storage method and device - Google Patents

Compression storage method and device Download PDF

Info

Publication number
CN106919617B
CN106919617B CN201511000457.3A CN201511000457A CN106919617B CN 106919617 B CN106919617 B CN 106919617B CN 201511000457 A CN201511000457 A CN 201511000457A CN 106919617 B CN106919617 B CN 106919617B
Authority
CN
China
Prior art keywords
parameters
compression
parameter
target
storage engine
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.)
Active
Application number
CN201511000457.3A
Other languages
Chinese (zh)
Other versions
CN106919617A (en
Inventor
王立新
杨挺
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Qihoo Technology Co Ltd
Original Assignee
Beijing Qihoo Technology Co Ltd
Qizhi Software Beijing Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Qihoo Technology Co Ltd, Qizhi Software Beijing Co Ltd filed Critical Beijing Qihoo Technology Co Ltd
Priority to CN201511000457.3A priority Critical patent/CN106919617B/en
Publication of CN106919617A publication Critical patent/CN106919617A/en
Application granted granted Critical
Publication of CN106919617B publication Critical patent/CN106919617B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06F16/2228Indexing structures
    • G06F16/2246Trees, e.g. B+trees
    • 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
    • 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/28Databases characterised by their database models, e.g. relational or object models
    • G06F16/284Relational databases

Landscapes

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

Abstract

本发明实施例提供了一种压缩存储方法和装置,其中的方法具体包括:获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;利用所述目标压缩方案对所述待存储数据进行压缩存储。本发明实施例能够最大化地发挥所述目标压缩方案的优势,从而能够大大提高数据库的吞吐量等性能。并且,本发明实施例可以选择最契合当前CPU核数的目标压缩算法,从而可以在保证数据库性能的同时,能够增加压缩存储的稳定性,且能够尽可能地节省数据库集群中存储设备的资源。

Figure 201511000457

Embodiments of the present invention provide a compression storage method and device, wherein the method specifically includes: acquiring compression parameters of data to be stored, and/or acquiring device parameters of a storage device corresponding to the data to be stored; according to the compression parameters and/or device parameters, select a target compression scheme corresponding to the data to be stored; use the target compression scheme to compress and store the data to be stored. The embodiments of the present invention can maximize the advantages of the target compression scheme, thereby greatly improving the throughput and other performance of the database. Moreover, the embodiment of the present invention can select a target compression algorithm that best fits the current number of CPU cores, so that while ensuring database performance, the stability of compressed storage can be increased, and resources of storage devices in the database cluster can be saved as much as possible.

Figure 201511000457

Description

一种压缩存储方法和装置A compressed storage method and device

技术领域technical field

本发明涉及计算机技术领域,特别是涉及一种压缩存储方法和装置。The present invention relates to the field of computer technology, and in particular, to a compression storage method and device.

背景技术Background technique

随着信息技术的发展,特别是Internet技术的发展,各领域的信息量都呈爆炸性增长趋势,高于1012字节的海量数据层出不穷。为了有效地管理海量数据,目前提出了压缩数据库技术,压缩数据库技术可以提高海量数据的存储效率,而且可以提高数据库的吞吐量等性能。With the development of information technology, especially the development of Internet technology, the amount of information in various fields has shown an explosive growth trend, and massive data larger than 10 12 bytes emerge in an endless stream. In order to effectively manage massive data, compressed database technology has been proposed at present. Compressed database technology can improve the storage efficiency of massive data, and can improve the performance of the database such as throughput.

现有方案通常采用InnoDB内部提供的zlib压缩算法进行海量数据的压缩存储;其中,InnoDB是MySQL数据库中应用最广的存储引擎,zlib可以提供数据压缩用的函数库,由此可以节省大约25%—50%左右的存储空间,且能够降低IO(输入输出,Input Output)消耗,及提升数据库的吞吐量。Existing solutions usually use the zlib compression algorithm provided by InnoDB to compress and store massive data; among them, InnoDB is the most widely used storage engine in MySQL databases, and zlib can provide a function library for data compression, which can save about 25% -50% storage space, and can reduce IO (input and output, Input Output) consumption, and improve the throughput of the database.

然而,在使用现有方案的过程中,有时会遇到这样的问题:在数据量基数较大的情况下、继续频繁的insert(插入)或者update(更新)操作时,InnoDB所使用B-tree(B-树)索引本身的特性容易导致数据库性能的显著下降,例如,可能导致数据库的吞吐量下降。However, in the process of using the existing solution, we sometimes encounter such a problem: in the case of a large data base, when frequent insert (insert) or update (update) operations are continued, the B-tree used by InnoDB The nature of the (B-tree) index itself tends to cause a significant drop in database performance, which may, for example, result in a drop in database throughput.

发明内容SUMMARY OF THE INVENTION

鉴于上述问题,提出了本发明以便提供一种克服上述问题或者至少部分地解决上述问题的一种压缩存储方法和装置。In view of the above problems, the present invention is proposed to provide a compressed storage method and apparatus that overcomes the above problems or at least partially solves the above problems.

依据本发明的一个方面,提供了一种压缩存储方法,包括:According to one aspect of the present invention, a compression storage method is provided, comprising:

获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;Obtain the compression parameters of the data to be stored, and/or obtain the device parameters of the storage device corresponding to the data to be stored;

依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;Selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters;

利用所述目标压缩方案对所述待存储数据进行压缩存储。The data to be stored is compressed and stored by using the target compression scheme.

可选地,所述压缩参数包括应用场景参数和/或数据库架构参数,则所述依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案的步骤,进一步包括:Optionally, the compression parameters include application scenario parameters and/or database architecture parameters, and the step of selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters further includes: :

从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;Select a target storage engine corresponding to the application scenario parameters and/or database schema parameters from at least one storage engine in the database;

从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A corresponding target compression algorithm is selected from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

可选地,所述从数据库的至少一种存储引擎中选择与所述应用场景参数对应的目标存储引擎的步骤,进一步包括:Optionally, the step of selecting a target storage engine corresponding to the application scenario parameter from at least one storage engine in the database further includes:

所述应用场景参数为第一应用场景参数,则选择对应的第一存储引擎为目标存储引擎;或者,If the application scenario parameter is the first application scenario parameter, select the corresponding first storage engine as the target storage engine; or,

所述应用场景参数为第二应用场景参数,则选择对应的第二存储引擎为目标存储引擎;If the application scenario parameter is the second application scenario parameter, then select the corresponding second storage engine as the target storage engine;

其中,所述第一应用场景参数包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。Wherein, the second application scenario parameters include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

可选地,所述从数据库的至少一种存储引擎中选择与所述数据库架构参数对应的目标存储引擎的步骤,进一步包括:Optionally, the step of selecting a target storage engine corresponding to the database schema parameter from at least one storage engine in the database further includes:

所述数据库架构参数为第一数据库架构参数,则选择对应的第三存储引擎为目标存储引擎;或者,If the database architecture parameter is the first database architecture parameter, the corresponding third storage engine is selected as the target storage engine; or,

所述数据库架构参数为第二数据库架构参数,则选择对应的第四存储引擎为目标存储引擎;If the database architecture parameter is the second database architecture parameter, the corresponding fourth storage engine is selected as the target storage engine;

其中,所述第一数据库架构参数包括:主从架构参数;或者,所述第二数据库架构参数包括:非主从架构参数。Wherein, the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameters include: non-master-slave architecture parameters.

可选地,所述压缩参数包括压缩指标参数,则所述依据所述压缩参数和/或设备参数,选择所述待存储数据对应的目标压缩方案的步骤,进一步包括:Optionally, the compression parameters include compression index parameters, and the step of selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters further includes:

从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A target compression algorithm that fits the compression index parameter and/or the device parameter is selected from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

可选地,所述设备参数包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。Optionally, the device parameters include at least one of the following parameters: CPU parameters, disk parameters and memory parameters.

可选地,所述压缩指标参数包括如下参数中的至少一种:压缩时间参数和压缩比参数。Optionally, the compression index parameter includes at least one of the following parameters: a compression time parameter and a compression ratio parameter.

可选地,所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法包括:Optionally, the target compression algorithm conforming to the compression index parameter and/or the device parameter includes:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

依据本发明的另一方面,提供了一种压缩存储装置,包括:According to another aspect of the present invention, a compressed storage device is provided, comprising:

获取模块,用于获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;an acquisition module, used for acquiring compression parameters of the data to be stored, and/or acquiring device parameters of the storage device corresponding to the data to be stored;

选择模块,用于依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;以及a selection module, configured to select a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters; and

压缩存储模块,用于利用所述目标压缩方案对所述待存储数据进行压缩存储。A compression storage module, configured to compress and store the data to be stored by using the target compression scheme.

可选地,所述压缩参数包括应用场景参数和/或数据库架构参数,则所述选择模块,进一步包括:Optionally, the compression parameters include application scenario parameters and/or database architecture parameters, and the selection module further includes:

第一选择子模块,用于从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;及a first selection submodule, configured to select a target storage engine corresponding to the application scenario parameters and/or database architecture parameters from at least one storage engine of the database; and

第二选择子模块,用于从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。The second selection sub-module is configured to select a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

可选地,所述第一选择子模块,进一步包括:Optionally, the first selection submodule further includes:

第一选择单元,用于在所述应用场景参数为第一应用场景参数时,选择对应的第一存储引擎为目标存储引擎;或者,a first selection unit, configured to select the corresponding first storage engine as the target storage engine when the application scenario parameter is the first application scenario parameter; or,

第二选择单元,用于在所述应用场景参数为第二应用场景参数时,选择对应的第二存储引擎为目标存储引擎;a second selection unit, configured to select the corresponding second storage engine as the target storage engine when the application scenario parameter is the second application scenario parameter;

其中,所述第一应用场景参数包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。Wherein, the second application scenario parameters include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

可选地,所述第一选择子模块,进一步包括:Optionally, the first selection submodule further includes:

第三选择单元,用于在所述数据库架构参数为第一数据库架构参数时,选择对应的第三存储引擎为目标存储引擎;或者,a third selection unit, configured to select the corresponding third storage engine as the target storage engine when the database schema parameter is the first database schema parameter; or,

第四选择单元,用于在所述数据库架构参数为第二数据库架构参数时,选择对应的第四存储引擎为目标存储引擎;a fourth selection unit, configured to select the corresponding fourth storage engine as the target storage engine when the database schema parameter is the second database schema parameter;

其中,所述第一数据库架构参数包括:主从架构参数;或者,所述第二数据库架构参数包括:非主从架构参数。Wherein, the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameters include: non-master-slave architecture parameters.

可选地,所述压缩参数包括压缩指标参数,则所述选择模块,进一步包括:Optionally, the compression parameters include compression index parameters, and the selection module further includes:

第三选择子模块,用于从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A third selection sub-module, configured to select a target compression algorithm that fits the compression index parameter and/or the device parameter from at least one compression algorithm of the target storage engine, the target storage engine and its corresponding target compression algorithm compose the target compression scheme.

可选地,所述设备参数包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。Optionally, the device parameters include at least one of the following parameters: CPU parameters, disk parameters and memory parameters.

可选地,所述压缩指标参数包括如下参数中的至少一种:压缩时间参数和压缩比参数。Optionally, the compression index parameter includes at least one of the following parameters: a compression time parameter and a compression ratio parameter.

可选地,所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法包括:Optionally, the target compression algorithm conforming to the compression index parameter and/or the device parameter includes:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

根据本发明实施例的一种压缩存储方法和装置,可以依据待压缩数据对应的压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;由于上述压缩参数可用于表示与待压缩数据的特性相关的参数,或者,上述压缩参数也可用于表示与待压缩数据的压缩需求相关的参数,或者,上述压缩参数也可用于表示与待压缩数据的存储环境相关的参数,故本发明实施例能够依据压缩参数选择得到最契合待压缩数据的特性、压缩需求、存储环境的目标压缩方案,因此,利用所述目标压缩方案对所述待存储数据进行压缩存储,能够最大化地发挥所述目标压缩方案的优势,从而能够大大提高数据库的吞吐量等性能。According to a compression storage method and device according to an embodiment of the present invention, a target compression scheme corresponding to the data to be stored can be selected according to the compression parameters and/or device parameters corresponding to the data to be compressed; Parameters related to the characteristics of the data to be compressed, or the above compression parameters can also be used to represent parameters related to the compression requirements of the data to be compressed, or the above compression parameters can also be used to represent parameters related to the storage environment of the data to be compressed, so In the embodiment of the present invention, a target compression scheme that best suits the characteristics, compression requirements, and storage environment of the data to be compressed can be selected according to the compression parameters. Therefore, using the target compression scheme to compress and store the data to be stored can maximize the The advantages of the target compression scheme are brought into play, so that the performance such as the throughput of the database can be greatly improved.

并且,由于上述设备参数可用于表征待存储数据对应的存储设备的性能,故本发明实施例可以选择最契合当前CPU核数的目标压缩算法,从而可以在保证数据库性能的同时,能够增加压缩存储的稳定性,且能够尽可能地节省数据库集群中存储设备的资源。In addition, since the above device parameters can be used to represent the performance of the storage device corresponding to the data to be stored, the embodiment of the present invention can select a target compression algorithm that best fits the current number of CPU cores, so that while ensuring the performance of the database, the compressed storage can be increased. It is stable and can save the resources of storage devices in the database cluster as much as possible.

上述说明仅是本发明技术方案的概述,为了能够更清楚了解本发明的技术手段,而可依照说明书的内容予以实施,并且为了让本发明的上述和其它目的、特征和优点能够更明显易懂,以下特举本发明的具体实施方式。The above description is only an overview of the technical solutions of the present invention, in order to be able to understand the technical means of the present invention more clearly, it can be implemented according to the content of the description, and in order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand , the following specific embodiments of the present invention are given.

附图说明Description of drawings

通过阅读下文可选实施方式的详细描述,各种其他的优点和益处对于本领域普通技术人员将变得清楚明了。附图仅用于示出可选实施方式的目的,而并不认为是对本发明的限制。而且在整个附图中,用相同的参考符号表示相同的部件。在附图中:Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of alternative embodiments. The drawings are for the purpose of illustrating alternative embodiments only and are not to be considered limiting of the invention. Also, the same components are denoted by the same reference numerals throughout the drawings. In the attached image:

图1示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图;1 shows a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention;

图2示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图;FIG. 2 shows a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention;

图3示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图;以及FIG. 3 shows a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention; and

图4示出了根据本发明一个实施例的一种压缩存储装置的结构示意图。FIG. 4 shows a schematic structural diagram of a compressed storage device according to an embodiment of the present invention.

具体实施方式Detailed ways

下面将参照附图更详细地描述本公开的示例性实施例。虽然附图中显示了本公开的示例性实施例,然而应当理解,可以以各种形式实现本公开而不应被这里阐述的实施例所限制。相反,提供这些实施例是为了能够更透彻地理解本公开,并且能够将本公开的范围完整的传达给本领域的技术人员。Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited by the embodiments set forth herein. Rather, these embodiments are provided so that the present disclosure will be more thoroughly understood, and will fully convey the scope of the present disclosure to those skilled in the art.

参照图1,示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图,具体可以包括如下步骤:Referring to FIG. 1, it shows a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention, which may specifically include the following steps:

步骤101、获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;Step 101: Obtain compression parameters of the data to be stored, and/or obtain device parameters of a storage device corresponding to the data to be stored;

步骤102、依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;Step 102, according to the compression parameters and/or device parameters, select a target compression scheme corresponding to the data to be stored;

步骤103、利用所述目标压缩方案对所述待存储数据进行压缩存储。Step 103: Compress and store the data to be stored by using the target compression scheme.

本发明实施例可适用于数据库中海量数据的压缩存储,其中,所述数据库可以包括ORACLE(甲骨文)、DB2、MySQL等类型的数据库等,可以理解,本发明实施例对于数据库的具体类型不加以限制。为了便于说明,本发明实施例均以MySQL为例进行描述,其它类型的数据库相互参照即可。The embodiment of the present invention is applicable to the compressed storage of massive data in the database, wherein the database may include databases such as ORACLE (Oracle), DB2, MySQL, etc. It can be understood that the embodiment of the present invention does not specify the specific type of the database. limit. For the convenience of description, the embodiments of the present invention are described by taking MySQL as an example, and other types of databases may be referred to each other.

本发明实施例中,上述压缩参数可用于表示与待压缩数据的特性相关的参数,如用于衡量待压缩数据的数据量大小的参数;或者,上述压缩参数也可用于表示与待压缩数据的压缩需求相关的参数,例如,用于衡量待压缩数据的应用场景的应用场景参数,又如,用于衡量待压缩数据的压缩指标的压缩指标参数等;或者,上述压缩参数也可用于表示与待压缩数据的存储环境相关的参数,如用于衡量待压缩数据的数据库环境的数据库架构参数等。由于本发明实施例能够依据压缩参数选择得到最契合上述压缩参数的目标压缩方案,因此,利用所述目标压缩方案对所述待存储数据进行压缩存储,能够最大化地发挥所述目标压缩方案的优势,从而能够大大提高数据库的吞吐量等性能。In this embodiment of the present invention, the above-mentioned compression parameters may be used to represent parameters related to the characteristics of the data to be compressed, such as parameters used to measure the data size of the data to be compressed; or, the above-mentioned compression parameters may also be used to represent the parameters related to the data to be compressed. Parameters related to compression requirements, for example, application scenario parameters used to measure the application scenario of the data to be compressed, or compression index parameters used to measure the compression index of the data to be compressed; Parameters related to the storage environment of the data to be compressed, such as database architecture parameters used to measure the database environment of the data to be compressed. Since the embodiment of the present invention can select a target compression scheme that best fits the above compression parameters according to the compression parameters, using the target compression scheme to compress and store the data to be stored can maximize the performance of the target compression scheme. Advantages, which can greatly improve the performance of the database throughput and so on.

本发明实施例中,上述目标压缩方案具体可以包括:目标存储引擎和所述目标引擎对应的目标压缩算法。其中,上述目标存储引擎可以为用户指定的存储引擎,也可以为通过本发明实施例选择得到的存储引擎。其中,上述存储引擎可用于负责数据库中数据的存储、为存储的数据建立索引、数据的查询等更新等一系列事务的功能系统。In the embodiment of the present invention, the above-mentioned target compression scheme may specifically include: a target storage engine and a target compression algorithm corresponding to the target engine. The above-mentioned target storage engine may be a storage engine designated by a user, or may be a storage engine selected through the embodiment of the present invention. Among them, the above-mentioned storage engine can be used for a functional system that is responsible for a series of transactions such as storage of data in the database, establishment of indexes for stored data, and updating of data such as querying.

在本发明的一种可选实施例中,MySQL数据库的存储引擎具体可以包括:ISAM、MyISAM、HEAP、InnoDB和TokuDB等,则本发明实施例可以依据压缩参数选择得到最契合上述压缩参数的目标存储引擎。In an optional embodiment of the present invention, the storage engine of the MySQL database may specifically include: ISAM, MyISAM, HEAP, InnoDB, TokuDB, etc., then the embodiment of the present invention can select the target that best fits the above compression parameters according to the compression parameters. storage engine.

在本发明的一种应用示例1中,相对于现有方案在数据量基数较大的情况下、继续频繁的insert或者update操作、所导致的数据库性能的显著下降的问题,本发明实施例可以依据数据量基数较大的情况,得到对应的大数据量参数或者联机分析处理场景参数,或者,可以依据数据量基数较大的情况和继续频繁的insert或者update操作的特性,得到对应的批量装载和读密集场景参数,并选择契合上述大数据量参数或者联机分析处理场景参数或者批量装载和读密集场景参数的TokuDB作为目标存储引擎;由于TokuDB的索引结构是Fractal Tree,而Fractal Tree相对于B-tree具有insert性能更强、不易产生“碎片”的优势,故TokuDB具有压缩比更高、批量装载性能更好的优势,因此,本发明实施例选择得到的TokuDB能够对上述应用示例1对应的待压缩数据进行有效地压缩存储,从而可以尽可能地提高数据库的吞吐量等性能。In an application example 1 of the present invention, compared with the existing solution, in the case of a large data base, frequent insert or update operations continue to cause a significant drop in database performance, the embodiment of the present invention can According to the large data volume base, the corresponding large data volume parameters or online analysis and processing scenario parameters can be obtained, or, according to the large data volume base and the characteristics of continuous frequent insert or update operations, the corresponding batch loading can be obtained. and read-intensive scenario parameters, and select TokuDB that fits the above large data volume parameters or online analytical processing scenario parameters or batch loading and read-intensive scenario parameters as the target storage engine; since the index structure of TokuDB is Fractal Tree, and Fractal Tree is relative to B -tree has the advantages of stronger insert performance and less "fragmentation", so TokuDB has the advantages of higher compression ratio and better batch loading performance. Therefore, the TokuDB selected in the embodiment of the present invention can be used for the above application example 1. The data to be compressed is effectively compressed and stored, so that the performance such as the throughput of the database can be improved as much as possible.

本发明实施例中,上述设备参数可用于表征待存储数据对应的存储设备的性能。在本发明的一种可选实施例中,所述设备参数具体可以包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。In this embodiment of the present invention, the foregoing device parameters may be used to represent the performance of the storage device corresponding to the data to be stored. In an optional embodiment of the present invention, the device parameters may specifically include at least one of the following parameters: CPU parameters, disk parameters, and memory parameters.

在本发明的一种可选实施例中,不同压缩算法所产生的CPU消耗是不同的,因此可以针对各压缩算法获取对应的目标CPU参数,并依据与待存储数据对应的存储设备的当前CPU参数选择对应的压缩算法。例如,存储设备的当前CPU核(core)数为6核,而第一目标压缩算法要求CPU核数在8核以上,第二目标压缩算法要求CPU核数在4核-8核之间,第三目标压缩算法要求CPU核数在4核以下,因此可以选择最契合当前CPU核数的目标压缩算法,从而可以在保证数据库性能的同时,尽可能地节省存储设备的资源。In an optional embodiment of the present invention, the CPU consumption generated by different compression algorithms is different, so the corresponding target CPU parameters can be obtained for each compression algorithm, and according to the current CPU of the storage device corresponding to the data to be stored The parameter selects the corresponding compression algorithm. For example, the current number of CPU cores (cores) of the storage device is 6 cores, and the first target compression algorithm requires more than 8 CPU cores, the second target compression algorithm requires CPU cores between 4 cores and 8 cores, and the third target compression algorithm requires the number of CPU cores to be between 4 and 8. The three-target compression algorithm requires the number of CPU cores to be less than 4 cores. Therefore, you can choose the target compression algorithm that best fits the current number of CPU cores, thereby ensuring database performance and saving storage device resources as much as possible.

需要说明的是,本发明实施例的压缩存储流程可由压缩存储装置来执行。则在本发明的一种可选实施例中,本领域技术人员可以依据待压缩数据的特性、压缩需求、存储环境等因素参数确定待压缩数据的压缩参数,并通过第一预置接口向上述压缩存储装置输入确定的压缩参数。或者,本领域技术人员可以首先确定待存储数据对应的存储设备,然后获取存储设备的设备参数,并通过第二预置接口向上述压缩存储装置输入获取的设备参数。It should be noted that, the compressed storage process in the embodiment of the present invention may be executed by a compressed storage device. In an optional embodiment of the present invention, those skilled in the art can determine the compression parameters of the data to be compressed according to the characteristics of the data to be compressed, compression requirements, storage environment and other factors and parameters, and send the data to the above-mentioned data through the first preset interface. The compression storage device inputs the determined compression parameters. Alternatively, those skilled in the art may first determine the storage device corresponding to the data to be stored, then obtain the device parameters of the storage device, and input the obtained device parameters into the above-mentioned compressed storage device through the second preset interface.

在本发明的另一种可选实施例中,上述压缩存储装置还可以首先获取待压缩数据的特性、压缩需求、存储环境等因素参数,然后依据上述因素参数确定待压缩数据的压缩参数,其中,上述因素参数可通过第三预置接口采集得到,也可由上述压缩存储装置通过访问数据库得到,本发明实施例对于上述因素参数的具体获取方式不加以限制。或者,上述压缩存储装置还可以通过访问待存储数据对应的存储设备,获取存储设备的设备参数。可以理解,本发明实施例对于上述压缩参数和上述设备参数的具体获取过程不加以限制。In another optional embodiment of the present invention, the above-mentioned compressing storage device may first obtain factors such as characteristics of the data to be compressed, compression requirements, storage environment, etc., and then determine the compression parameters of the data to be compressed according to the above-mentioned factors and parameters, wherein , the above-mentioned factor parameters can be acquired through a third preset interface, or can be obtained by the above-mentioned compressed storage device by accessing a database. The embodiment of the present invention does not limit the specific acquisition method of the above-mentioned factor parameters. Alternatively, the above-mentioned compressed storage apparatus may also obtain the device parameters of the storage device by accessing the storage device corresponding to the data to be stored. It can be understood that the embodiments of the present invention do not limit the specific acquisition process of the above-mentioned compression parameters and the above-mentioned device parameters.

综上,本发明实施例依据待压缩数据对应的压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;由于上述压缩参数可用于表示与待压缩数据的特性相关的参数,或者,上述压缩参数也可用于表示与待压缩数据的压缩需求相关的参数,或者,上述压缩参数也可用于表示与待压缩数据的存储环境相关的参数,故本发明实施例能够依据压缩参数选择得到最契合待压缩数据的特性、压缩需求、存储环境的目标压缩方案,因此,利用所述目标压缩方案对所述待存储数据进行压缩存储,能够最大化地发挥所述目标压缩方案的优势,从而能够大大提高数据库的吞吐量等性能。To sum up, the embodiment of the present invention selects a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters corresponding to the data to be compressed; since the above compression parameters can be used to represent parameters related to the characteristics of the data to be compressed , or the above compression parameters can also be used to represent parameters related to the compression requirements of the data to be compressed, or the above compression parameters can also be used to represent parameters related to the storage environment of the data to be compressed, so the embodiment of the present invention can be based on the compression parameters Select the target compression scheme that best fits the characteristics, compression requirements, and storage environment of the data to be compressed. Therefore, using the target compression scheme to compress and store the to-be-stored data can maximize the advantages of the target compression scheme , which can greatly improve the throughput and other performance of the database.

并且,由于上述设备参数可用于表征待存储数据对应的存储设备的性能,故本发明实施例可以选择最契合当前CPU核数的目标压缩算法,从而可以在保证数据库性能的同时,能够增加压缩存储的稳定性,且能够尽可能地节省数据库集群中存储设备的资源。In addition, since the above device parameters can be used to represent the performance of the storage device corresponding to the data to be stored, the embodiment of the present invention can select a target compression algorithm that best fits the current number of CPU cores, so that while ensuring the performance of the database, the compressed storage can be increased. It is stable and can save the resources of storage devices in the database cluster as much as possible.

参照图2,示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图,具体可以包括如下步骤:Referring to FIG. 2, it shows a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention, which may specifically include the following steps:

步骤201、获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;Step 201, obtaining compression parameters of the data to be stored, and/or obtaining device parameters of a storage device corresponding to the data to be stored;

步骤202、依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;Step 202, according to the compression parameters and/or device parameters, select a target compression scheme corresponding to the data to be stored;

步骤203、利用所述目标压缩方案对所述待存储数据进行压缩存储;Step 203, using the target compression scheme to compress and store the data to be stored;

相对于图1所示实施例,本实施例中的压缩参数具体可以包括应用场景参数和/或数据库架构参数,则上述步骤202可以进一步包括:With respect to the embodiment shown in FIG. 1 , the compression parameters in this embodiment may specifically include application scenario parameters and/or database architecture parameters, and the foregoing step 202 may further include:

步骤221、从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;Step 221: Select a target storage engine corresponding to the application scenario parameters and/or database architecture parameters from at least one storage engine in the database;

步骤222、从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法可组成所述目标压缩方案。Step 222: Select a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm may constitute the target compression scheme.

本实施例从数据库的至少一种存储引擎中,选择最契合所述应用场景参数和/或数据库架构参数的目标存储引擎,并通过上述目标存储引擎进行压缩存储,因此,能够在尽可能发挥上述目标存储引擎的优势的情况下、对待压缩数据进行有效地压缩存储,从而可以尽可能地提高数据库的吞吐量等性能。In this embodiment, a target storage engine that best fits the application scenario parameters and/or database architecture parameters is selected from at least one storage engine in the database, and the above-mentioned target storage engine is used to compress and store. In the case of the advantages of the target storage engine, the data to be compressed is effectively compressed and stored, so that the performance such as the throughput of the database can be improved as much as possible.

在本发明的一种可选实施例中,可以通过互联网抓取数据库的每个存储引擎的资源信息,并对上述资源信息进行分析以得到每个存储引擎对应的优势关键词和劣势关键词,这样,在实施步骤221的过程中,可以将所述应用场景参数和/或数据库架构参数与上述优势关键词或者劣势关键词进行匹配,若与劣势关键词匹配成功,则可以排除对应的存储引擎,若与优势关键词匹配成功,则可以将对应的存储引擎作为备选存储引擎。其中,在备选存储引擎的数目大于1时,可以依据匹配成功的优势关键词的数目等方式从备选存储引擎中选择一个作为目标存储引擎,或者,可以将所有备选存储引擎输出以使用户从中选择一个目标存储引擎。在备选存储引擎的数目等于1时,可以直接将该备选存储引擎作为目标存储引擎。In an optional embodiment of the present invention, the resource information of each storage engine of the database can be captured through the Internet, and the above resource information can be analyzed to obtain the advantage keywords and disadvantage keywords corresponding to each storage engine, In this way, in the process of implementing step 221, the application scenario parameters and/or database architecture parameters can be matched with the above-mentioned advantageous keywords or disadvantaged keywords. If the matching with the disadvantaged keywords is successful, the corresponding storage engine can be excluded. , if it is successfully matched with the dominant keyword, the corresponding storage engine can be used as an alternative storage engine. Wherein, when the number of alternative storage engines is greater than 1, one of the alternative storage engines may be selected as the target storage engine according to the number of successfully matched advantageous keywords, etc., or all alternative storage engines may be output to make The user selects a target storage engine from it. When the number of candidate storage engines is equal to 1, the candidate storage engine can be directly used as the target storage engine.

可以理解,上述优势关键词和劣势关键词的获取过程只是作为可选实施例,实际上,本领域技术人员还可以根据实际应用需求采用目标存储引擎的其他选择过程,如通过第五预置接口接收用户输入的优势关键词和劣势关键词,或者,可以通过分析存储引擎的历史使用记录、或者用户对于存储引擎的评论数据,以得到每个存储引擎对应的优势关键词和劣势关键词等,本发明实施例对于每个存储引擎对应的优势关键词和劣势关键词的获取过程不加以限制。It can be understood that the above process of obtaining the advantageous keywords and disadvantaged keywords is only an optional embodiment. In fact, those skilled in the art can also adopt other selection processes of the target storage engine according to actual application requirements, such as through the fifth preset interface. Receive the advantage keywords and disadvantage keywords input by the user, or, by analyzing the historical usage records of the storage engine or the user's comment data on the storage engine, to obtain the advantage keywords and disadvantage keywords corresponding to each storage engine, etc., The embodiments of the present invention do not limit the acquisition process of the advantageous keywords and disadvantaged keywords corresponding to each storage engine.

本发明实施例可以提供从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎的如下选择方案:Embodiments of the present invention may provide the following selection scheme for selecting a target storage engine corresponding to the application scenario parameters and/or database architecture parameters from at least one storage engine of a database:

选择方案1Choose option 1

选择方案1中,所述从数据库的至少一种存储引擎中选择与所述应用场景参数对应的目标存储引擎的步骤,可以进一步包括:In option 1, the step of selecting a target storage engine corresponding to the application scenario parameter from at least one storage engine in the database may further include:

步骤A1、所述应用场景参数为第一应用场景参数,则选择对应的第一存储引擎为目标存储引擎;或者,Step A1, the application scenario parameter is the first application scenario parameter, then select the corresponding first storage engine as the target storage engine; or,

步骤A2、所述应用场景参数为第二应用场景参数,则选择对应的第二存储引擎为目标存储引擎;Step A2, the application scenario parameter is the second application scenario parameter, then select the corresponding second storage engine as the target storage engine;

其中,所述第一应用场景参数具体可以包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters may specifically include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数具体可以包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。The second application scenario parameters may specifically include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

本发明实施例中,OLTP(联机事务处理,On-Line Transaction Processing)是传统的关系型数据库的主要应用,主要用于基本的、日常的事务处理,例如银行交易。由于OLTP场景通常涉及单条或者少数数据库记录的insert、update、删除、查询等操作;而InnoDB可以充分利用CPU多核/高频的优势,同时降低IO消耗,提升了吞吐量,特别适合读密集型应用,因此,在本发明的一种可选实施例中,上述第一存储引擎具体可以包括:InnoDB。可以理解,契合联机事务处理场景参数和/或读密集场景参数的任意存储引擎均可以作为上述第一存储引擎,本发明实施例对于具体的第一存储引擎不加以限制。In the embodiment of the present invention, OLTP (On-Line Transaction Processing) is the main application of a traditional relational database, and is mainly used for basic, daily transaction processing, such as bank transactions. Since OLTP scenarios usually involve operations such as insert, update, delete, and query of a single or few database records, InnoDB can make full use of the advantages of CPU multi-core/high frequency, while reducing IO consumption and improving throughput, which is especially suitable for read-intensive applications , therefore, in an optional embodiment of the present invention, the above-mentioned first storage engine may specifically include: InnoDB. It can be understood that any storage engine that conforms to the online transaction processing scenario parameters and/or the read-intensive scenario parameters can be used as the above-mentioned first storage engine, and the embodiment of the present invention does not limit the specific first storage engine.

OLAP(联机分析处理,Online Analytical Processing)是数据仓库系统的主要应用,其支持复杂的分析操作,侧重决策支持,并且提供直观易懂的查询结果。由于OLTP场景通常涉及批量数据库记录的装载,而TokuDB具有批量装载性能更好、插入性能更优的优势,因此,在本发明的一种可选实施例中,上述第二存储引擎具体可以包括:TokuDB。可以理解,契合联机分析处理场景参数和/或批量装载和读密集场景参数的任意存储引擎均可以作为上述第二存储引擎,本发明实施例对于具体的第二存储引擎不加以限制。OLAP (Online Analytical Processing) is the main application of the data warehouse system, which supports complex analysis operations, focuses on decision support, and provides intuitive and easy-to-understand query results. Since the OLTP scenario usually involves the loading of batch database records, and TokuDB has the advantages of better batch loading performance and better insertion performance, in an optional embodiment of the present invention, the above-mentioned second storage engine may specifically include: TokuDB. It can be understood that any storage engine that conforms to the online analytical processing scenario parameters and/or the batch loading and read-intensive scenario parameters can be used as the second storage engine, and the embodiment of the present invention does not limit the specific second storage engine.

选择方案2Choose option 2

选择方案2中,所述从数据库的至少一种存储引擎中选择与所述数据库架构参数对应的目标存储引擎的步骤,可以进一步包括:In option 2, the step of selecting a target storage engine corresponding to the database schema parameter from at least one storage engine in the database may further include:

步骤B1、所述数据库架构参数为第一数据库架构参数,则选择对应的第三存储引擎为目标存储引擎;或者,Step B1, the database architecture parameter is the first database architecture parameter, then select the corresponding third storage engine as the target storage engine; or,

步骤B2、所述数据库架构参数为第二数据库架构参数,则选择对应的第四存储引擎为目标存储引擎;Step B2, the database architecture parameter is the second database architecture parameter, then select the corresponding fourth storage engine as the target storage engine;

其中,所述第一数据库架构参数具体可以包括:主从架构参数;或者,所述第二数据库架构参数具体可以包括:非主从架构参数。Wherein, the first database architecture parameters may specifically include: master-slave architecture parameters; or, the second database architecture parameters may specifically include: non-master-slave architecture parameters.

本发明实施例中,上述主从架构参数可用于表征数据库架构支持主从复制的架构。采用主从架构,在主服务器发生故障,可以使用从服务器来提供服务,因此可以提供数据库的稳定性。并且,在主从服务器上分开处理用户的请求,可以提升数据处理效率。另外将主服务器上的数据复制到从服务器上,保护数据免受意外的损失。In the embodiment of the present invention, the above-mentioned master-slave architecture parameters may be used to represent the architecture in which the database architecture supports master-slave replication. Using the master-slave architecture, when the master server fails, the slave server can be used to provide services, so the stability of the database can be provided. Moreover, processing user requests separately on the master and slave servers can improve data processing efficiency. In addition, the data on the master server is copied to the slave server to protect the data from accidental loss.

本发明实施例经研究发现,TokuDB目前在主从架构支持上存在缺陷,也即,TokuDB与主从结构的兼容性存在问题,而InnoDB可以较好地支持主从架构。故在本发明的一种可选实施例中,上述第一存储引擎具体可以包括:InnoDB,上述第二存储引擎具体可以包括:TokuDB。可以理解,契合主从架构参数的任意存储引擎均可以作为上述第一存储引擎,契合非主从架构参数的任意存储引擎均可以作为上述第二存储引擎;本发明实施例对于具体的第一存储引擎和第二存储引擎不加以限制。It is found through research in the embodiment of the present invention that TokuDB currently has defects in the support of the master-slave architecture, that is, the compatibility between TokuDB and the master-slave architecture is problematic, while InnoDB can better support the master-slave architecture. Therefore, in an optional embodiment of the present invention, the first storage engine may specifically include: InnoDB, and the second storage engine may specifically include: TokuDB. It can be understood that any storage engine that conforms to the parameters of the master-slave architecture can be used as the above-mentioned first storage engine, and any storage engine that conforms to the parameters of the non-master-slave architecture can be used as the above-mentioned second storage engine. The engine and the second storage engine are not limited.

参照图3,示出了根据本发明一个实施例的一种压缩存储方法的步骤流程示意图,具体可以包括如下步骤:Referring to FIG. 3, a schematic flowchart of steps of a compressed storage method according to an embodiment of the present invention is shown, which may specifically include the following steps:

步骤301、获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;Step 301: Obtain compression parameters of the data to be stored, and/or obtain device parameters of a storage device corresponding to the data to be stored;

步骤302、依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;Step 302, according to the compression parameters and/or device parameters, select a target compression scheme corresponding to the data to be stored;

步骤303、利用所述目标压缩方案对所述待存储数据进行压缩存储;Step 303, using the target compression scheme to compress and store the data to be stored;

相对于图1所示实施例,本实施例中的压缩参数具体可以包括压缩指标参数,则上述步骤302可以进一步包括:Compared with the embodiment shown in FIG. 1 , the compression parameters in this embodiment may specifically include compression index parameters, and the foregoing step 302 may further include:

步骤321、从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法可组成所述目标压缩方案。Step 321: Select a target compression algorithm that fits the compression index parameter and/or the device parameter from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm can form the target compression scheme.

压缩指标参数可用于表征待存储数据的压缩指标,例如,压缩指标参数具体可以包括如下参数中的至少一种:压缩时间参数和压缩比参数。上述压缩时间参数可用于表征压缩存储所花费的时间,压缩比参数可用于表征压缩后数据相对于待存储数据的空间占比。本实施例从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,能够在保证压缩存储的稳定性、及节省数据库集群中存储设备的资源的同时,尽可能实现最优的压缩指标。The compression index parameter may be used to represent the compression index of the data to be stored. For example, the compression index parameter may specifically include at least one of the following parameters: a compression time parameter and a compression ratio parameter. The above compression time parameter can be used to represent the time spent for compressing storage, and the compression ratio parameter can be used to represent the space ratio of the compressed data relative to the data to be stored. In this embodiment, a target compression algorithm that fits the compression index parameters and/or the device parameters is selected from at least one compression algorithm of the target storage engine, which can ensure the stability of compressed storage and save the time of storage devices in the database cluster. At the same time, the optimal compression index is achieved as much as possible.

在本发明的一种可选实施例中,假设上述目标存储引擎具有三种或者三种以上的目标压缩算法,则所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法具体可以包括:In an optional embodiment of the present invention, assuming that the above-mentioned target storage engine has three or more target compression algorithms, the target compression algorithm conforming to the compression index parameter and/or the device parameter is specific Can include:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

在本发明的一种应用示例中,假设上述目标存储引擎为TokuDB,TokuDB具有lzma算法、zlib算法和quicklz算法,其中,lzma算法、zlib算法和quicklz算法对应的压缩比参数分别为:2.626857、2.285948和1.700141;则可以根据上述压缩比参数设置lzma算法、zlib算法和quicklz算法对应的所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数,例如,针对lzma算法设置第一级压缩指标参数的第一区间为[2.3,2.7],针对zlib算法设置第二级压缩指标参数的第二区间为[1.8,2.29],针对quicklz算法设置第三级压缩指标参数的第三区间为[2,2.28],则可以将当前压缩指标参数与上述第一区间、第二区间和第三区间进行匹配,将匹配成功所对应的算法作为当前目标压缩算法。例如,当前压缩指标参数为2.4,则当前目标压缩算法可以为lzma算法。In an application example of the present invention, it is assumed that the above-mentioned target storage engine is TokuDB, and TokuDB has the lzma algorithm, the zlib algorithm and the quicklz algorithm, wherein the compression ratio parameters corresponding to the lzma algorithm, the zlib algorithm and the quicklz algorithm are respectively: 2.626857, 2.285948 and 1.700141; then the first-level compression index parameters, the second-level compression index parameters, and the third-level compression index parameters corresponding to the lzma algorithm, the zlib algorithm, and the quicklz algorithm can be set according to the above-mentioned compression ratio parameters, for example, set for the lzma algorithm The first interval of the first-level compression index parameter is [2.3, 2.7], the second interval of the second-level compression index parameter is set to [1.8, 2.29] for the zlib algorithm, and the third-level compression index parameter is set for the quicklz algorithm. If the three intervals are [2, 2.28], the current compression index parameter can be matched with the above-mentioned first interval, second interval and third interval, and the algorithm corresponding to the successful matching is used as the current target compression algorithm. For example, if the current compression index parameter is 2.4, the current target compression algorithm may be the lzma algorithm.

在本发明的另一种应用示例中,假设lzma算法、zlib算法和quicklz算法对应的CPU核数分别为:8核以上、4核-8核之间和4核以下;则可以将当前压缩指标参数与上述3种CPU核数进行匹配,将匹配成功所对应的算法作为当前目标压缩算法。例如,存储设备的当前CPU核数为6核,则可以选择最契合当前CPU核数的zlib算法。In another application example of the present invention, it is assumed that the number of CPU cores corresponding to the lzma algorithm, the zlib algorithm and the quicklz algorithm are respectively above 8 cores, between 4 cores and 8 cores, and below 4 cores; The parameters are matched with the above three CPU cores, and the algorithm corresponding to the successful matching is used as the current target compression algorithm. For example, if the current number of CPU cores of the storage device is 6 cores, the zlib algorithm that best fits the current number of CPU cores can be selected.

可以理解,上述压缩比参数和CPU核数可以组合使用,具体地,可以对两种压缩指标参数的匹配结果进行加权平均,并选择最高的加权平均结果所对应的压缩算法作为目标压缩算法等,可以理解,本发明实施例对于组合使用压缩比参数和CPU核数的具体过程不加以限制。It can be understood that the above compression ratio parameter and the number of CPU cores can be used in combination. Specifically, the matching results of the two compression index parameters can be weighted and averaged, and the compression algorithm corresponding to the highest weighted average result can be selected as the target compression algorithm, etc., It can be understood that the embodiment of the present invention does not limit the specific process of using the compression ratio parameter and the number of CPU cores in combination.

需要说明的是,上述CPU核数只是作为设备参数的可选实施例,实际上,上述设备参数还可以包括:用于表征磁盘性能的磁盘参数和用于表征内存性能的内存参数等,本发明实施例对于具体的设备参数不加以限制。It should be noted that the above-mentioned number of CPU cores is only an optional embodiment of the device parameters. In fact, the above-mentioned device parameters may also include: disk parameters used to characterize disk performance and memory parameters used to characterize memory performance, etc. The present invention The embodiment does not limit specific device parameters.

另外,需要说明的是,本实施例中的目标存储引擎可以为利用图2所示实施例选择的目标存储引擎,也可以为用户指定的存储引擎,本发明实施例对于上述目标存储引擎的具体获取过程不加以限制。In addition, it should be noted that the target storage engine in this embodiment may be the target storage engine selected by using the embodiment shown in FIG. 2, or may be the storage engine specified by the user. The acquisition process is not limited.

对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明实施例并不受所描述的动作顺序的限制,因为依据本发明实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于可选实施例,所涉及的动作并不一定是本发明实施例所必须的。For the method embodiments, for the sake of simple description, they are all expressed as a series of action combinations, but those skilled in the art should know that the embodiments of the present invention are not limited by the described sequence of actions, because according to the embodiments of the present invention , certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all optional embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

参照图4,示出了根据本发明一个实施例的一种压缩存储装置的结构示意图,具体可以包括如下模块:Referring to FIG. 4, a schematic structural diagram of a compressed storage device according to an embodiment of the present invention is shown, which may specifically include the following modules:

获取模块401,用于获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;an obtaining module 401, configured to obtain compression parameters of the data to be stored, and/or obtain device parameters of a storage device corresponding to the data to be stored;

选择模块402,用于依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;以及a selection module 402, configured to select a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters; and

压缩存储模块403,用于利用所述目标压缩方案对所述待存储数据进行压缩存储。The compression storage module 403 is configured to compress and store the data to be stored by using the target compression scheme.

在本发明的一种可选实施例中,所述压缩参数具体可以包括应用场景参数和/或数据库架构参数,则所述选择模块402,可以进一步包括:In an optional embodiment of the present invention, the compression parameters may specifically include application scenario parameters and/or database architecture parameters, and the selection module 402 may further include:

第一选择子模块,用于从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;及a first selection submodule, configured to select a target storage engine corresponding to the application scenario parameters and/or database architecture parameters from at least one storage engine of the database; and

第二选择子模块,用于从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法可组成所述目标压缩方案。The second selection sub-module is configured to select a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm can form the target compression scheme.

在本发明的另一种可选实施例中,所述第一选择子模块,可以进一步包括:In another optional embodiment of the present invention, the first selection sub-module may further include:

第一选择单元,用于在所述应用场景参数为第一应用场景参数时,选择对应的第一存储引擎为目标存储引擎;或者,a first selection unit, configured to select the corresponding first storage engine as the target storage engine when the application scenario parameter is the first application scenario parameter; or,

第二选择单元,用于在所述应用场景参数为第二应用场景参数时,选择对应的第二存储引擎为目标存储引擎;a second selection unit, configured to select the corresponding second storage engine as the target storage engine when the application scenario parameter is the second application scenario parameter;

其中,所述第一应用场景参数具体可以包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters may specifically include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数具体可以包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。The second application scenario parameters may specifically include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

在本发明的再一种可选实施例中,所述第一选择子模块,可以进一步包括:In yet another optional embodiment of the present invention, the first selection sub-module may further include:

第三选择单元,用于在所述数据库架构参数为第一数据库架构参数时,选择对应的第三存储引擎为目标存储引擎;或者,a third selection unit, configured to select the corresponding third storage engine as the target storage engine when the database schema parameter is the first database schema parameter; or,

第四选择单元,用于在所述数据库架构参数为第二数据库架构参数时,选择对应的第四存储引擎为目标存储引擎;a fourth selection unit, configured to select the corresponding fourth storage engine as the target storage engine when the database schema parameter is the second database schema parameter;

其中,所述第一数据库架构参数具体可以包括:主从架构参数;或者,所述第二数据库架构参数具体可以包括:非主从架构参数。Wherein, the first database architecture parameters may specifically include: master-slave architecture parameters; or, the second database architecture parameters may specifically include: non-master-slave architecture parameters.

在本发明的又一种可选实施例中,所述压缩参数具体可以包括压缩指标参数,则所述选择模块402,可以进一步包括:In another optional embodiment of the present invention, the compression parameters may specifically include compression index parameters, and the selection module 402 may further include:

第三选择子模块,用于从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法可组成所述目标压缩方案。A third selection sub-module, configured to select a target compression algorithm that fits the compression index parameter and/or the device parameter from at least one compression algorithm of the target storage engine, the target storage engine and its corresponding target compression algorithm The target compression scheme can be composed.

在本发明的一种可选实施例中,所述设备参数具体可以包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。In an optional embodiment of the present invention, the device parameters may specifically include at least one of the following parameters: CPU parameters, disk parameters, and memory parameters.

在本发明的另一种可选实施例中,所述压缩指标参数具体可以包括如下参数中的至少一种:压缩时间参数和压缩比参数。In another optional embodiment of the present invention, the compression index parameter may specifically include at least one of the following parameters: a compression time parameter and a compression ratio parameter.

在本发明的再一种可选实施例中,所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法具体可以包括:In yet another optional embodiment of the present invention, the target compression algorithm conforming to the compression index parameter and/or the device parameter may specifically include:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

对于装置实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and reference may be made to the partial description of the method embodiment for related parts.

在此提供的算法和显示不与任何特定计算机、虚拟系统或者其它设备固有相关。各种通用系统也可以与基于在此的示教一起使用。根据上面的描述,构造这类系统所要求的结构是显而易见的。此外,本发明也不针对任何特定编程语言。应当明白,可以利用各种编程语言实现在此描述的本发明的内容,并且上面对特定语言所做的描述是为了披露本发明的最佳实施方式。The algorithms and displays provided herein are not inherently related to any particular computer, virtual system, or other device. Various general-purpose systems can also be used with teaching based on this. The structure required to construct such a system is apparent from the above description. Furthermore, the present invention is not directed to any particular programming language. It is to be understood that various programming languages may be used to implement the inventions described herein, and that the descriptions of specific languages above are intended to disclose the best mode for carrying out the invention.

在此处所提供的说明书中,说明了大量具体细节。然而,能够理解,本发明的实施例可以在没有这些具体细节的情况下实践。在一些实例中,并未详细示出公知的方法、结构和技术,以便不模糊对本说明书的理解。In the description provided herein, numerous specific details are set forth. It will be understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.

类似地,应当理解,为了精简本公开并帮助理解各个发明方面中的一个或多个,在上面对本发明的示例性实施例的描述中,本发明的各个特征有时被一起分组到单个实施例、图、或者对其的描述中。然而,并不应将该公开的方法解释成反映如下意图:即所要求保护的本发明要求比在每个权利要求中所明确记载的特征更多的特征。更确切地说,如下面的权利要求书所反映的那样,发明方面在于少于前面公开的单个实施例的所有特征。因此,遵循具体实施方式的权利要求书由此明确地并入该具体实施方式,其中每个权利要求本身都作为本发明的单独实施例。Similarly, it is to be understood that in the above description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together into a single embodiment, figure, or its description. This disclosure, however, should not be construed as reflecting an intention that the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the Detailed Description are hereby expressly incorporated into this Detailed Description, with each claim standing on its own as a separate embodiment of this invention.

本领域那些技术人员可以理解,可以对实施例中的设备中的模块进行自适应性地改变并且把它们设置在与该实施例不同的一个或多个设备中。可以把实施例中的模块或单元或组件组合成一个模块或单元或组件,以及此外可以把它们分成多个子模块或子单元或子组件。除了这样的特征和/或过程或者单元中的至少一些是相互排斥之外,可以采用任何组合对本说明书(包括伴随的权利要求、摘要和附图)中公开的所有特征以及如此公开的任何方法或者设备的所有过程或单元进行组合。除非另外明确陈述,本说明书(包括伴随的权利要求、摘要和附图)中公开的每个特征可以由提供相同、等同或相似目的的替代特征来代替。Those skilled in the art will understand that the modules in the device in the embodiment can be adaptively changed and arranged in one or more devices different from the embodiment. The modules or units or components in the embodiments may be combined into one module or unit or component, and further they may be divided into multiple sub-modules or sub-units or sub-assemblies. All features disclosed in this specification (including accompanying claims, abstract and drawings) and any method so disclosed may be employed in any combination, unless at least some of such features and/or procedures or elements are mutually exclusive. All processes or units of equipment are combined. Each feature disclosed in this specification (including accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.

此外,本领域的技术人员能够理解,尽管在此所述的一些实施例包括其它实施例中所包括的某些特征而不是其它特征,但是不同实施例的特征的组合意味着处于本发明的范围之内并且形成不同的实施例。例如,在下面的权利要求书中,所要求保护的实施例的任意之一都可以以任意的组合方式来使用。Furthermore, those skilled in the art will appreciate that although some of the embodiments described herein include certain features, but not others, included in other embodiments, that combinations of features of different embodiments are intended to be within the scope of the invention within and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.

本发明的各个部件实施例可以以硬件实现,或者以在一个或者多个处理器上运行的软件模块实现,或者以它们的组合实现。本领域的技术人员应当理解,可以在实践中使用微处理器或者数字信号处理器(DSP)来实现根据本发明实施例的压缩存储方法和装置中的一些或者全部部件的一些或者全部功能。本发明还可以实现为用于执行这里所描述的方法的一部分或者全部的设备或者装置程序(例如,计算机程序和计算机程序产品)。这样的实现本发明的程序可以存储在计算机可读介质上,或者可以具有一个或者多个信号的形式。这样的信号可以从因特网平台上下载得到,或者在载体信号上提供,或者以任何其他形式提供。Various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art should understand that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all of the components in the compressed storage method and apparatus according to the embodiments of the present invention. The present invention can also be implemented as apparatus or apparatus programs (eg, computer programs and computer program products) for performing part or all of the methods described herein. Such a program implementing the present invention may be stored on a computer-readable medium, or may be in the form of one or more signals. Such signals may be downloaded from Internet platforms, or provided on carrier signals, or in any other form.

应该注意的是上述实施例对本发明进行说明而不是对本发明进行限制,并且本领域技术人员在不脱离所附权利要求的范围的情况下可设计出替换实施例。在权利要求中,不应将位于括号之间的任何参考符号构造成对权利要求的限制。单词“包括”不排除存在未列在权利要求中的元件或步骤。位于元件之前的单词“一”或“一个”不排除存在多个这样的元件。本发明可以借助于包括有若干不同元件的硬件以及借助于适当编程的计算机来实现。在列举了若干装置的单元权利要求中,这些装置中的若干个可以是通过同一个硬件项来具体体现。单词第一、第二、以及第三等的使用不表示任何顺序。可将这些单词解释为名称。It should be noted that the above-described embodiments illustrate rather than limit the invention, and that alternative embodiments may be devised by those skilled in the art without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention can be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by one and the same item of hardware. The use of the words first, second, and third, etc. do not denote any order. These words can be interpreted as names.

本发明公开了A1、一种压缩存储方法,包括:The invention discloses A1, a compression storage method, comprising:

获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;Obtain the compression parameters of the data to be stored, and/or obtain the device parameters of the storage device corresponding to the data to be stored;

依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;Selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters;

利用所述目标压缩方案对所述待存储数据进行压缩存储。The data to be stored is compressed and stored by using the target compression scheme.

A2、如A1所述的方法,所述压缩参数包括应用场景参数和/或数据库架构参数,则所述依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案的步骤,进一步包括:A2. The method according to A1, wherein the compression parameters include application scene parameters and/or database architecture parameters, then the target compression scheme corresponding to the data to be stored is selected according to the compression parameters and/or device parameters The steps further include:

从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;Select a target storage engine corresponding to the application scenario parameters and/or database schema parameters from at least one storage engine in the database;

从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A corresponding target compression algorithm is selected from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

A3、如A2所述的方法,所述从数据库的至少一种存储引擎中选择与所述应用场景参数对应的目标存储引擎的步骤,进一步包括:A3. The method according to A2, wherein the step of selecting a target storage engine corresponding to the application scenario parameter from at least one storage engine in the database further includes:

所述应用场景参数为第一应用场景参数,则选择对应的第一存储引擎为目标存储引擎;或者,If the application scenario parameter is the first application scenario parameter, select the corresponding first storage engine as the target storage engine; or,

所述应用场景参数为第二应用场景参数,则选择对应的第二存储引擎为目标存储引擎;If the application scenario parameter is the second application scenario parameter, then select the corresponding second storage engine as the target storage engine;

其中,所述第一应用场景参数包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。Wherein, the second application scenario parameters include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

A4、如A2所述的方法,所述从数据库的至少一种存储引擎中选择与所述数据库架构参数对应的目标存储引擎的步骤,进一步包括:A4. The method according to A2, wherein the step of selecting a target storage engine corresponding to the database schema parameter from at least one storage engine in the database further comprises:

所述数据库架构参数为第一数据库架构参数,则选择对应的第三存储引擎为目标存储引擎;或者,If the database architecture parameter is the first database architecture parameter, the corresponding third storage engine is selected as the target storage engine; or,

所述数据库架构参数为第二数据库架构参数,则选择对应的第四存储引擎为目标存储引擎;If the database architecture parameter is the second database architecture parameter, the corresponding fourth storage engine is selected as the target storage engine;

其中,所述第一数据库架构参数包括:主从架构参数;或者,所述第二数据库架构参数包括:非主从架构参数。Wherein, the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameters include: non-master-slave architecture parameters.

A5、如A1所述的方法,所述压缩参数包括压缩指标参数,则所述依据所述压缩参数和/或设备参数,选择所述待存储数据对应的目标压缩方案的步骤,进一步包括:A5. The method according to A1, wherein the compression parameters include compression index parameters, and the step of selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters further includes:

从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A target compression algorithm that fits the compression index parameter and/or the device parameter is selected from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

A6、如A5所述的方法,所述设备参数包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。A6. The method according to A5, wherein the device parameters include at least one of the following parameters: a CPU parameter, a disk parameter, and a memory parameter.

A7、如A5所述的方法,所述压缩指标参数包括如下参数中的至少一种:压缩时间参数和压缩比参数。A7. The method according to A5, wherein the compression index parameter includes at least one of the following parameters: a compression time parameter and a compression ratio parameter.

A8、如A5至A7中任一所述的方法,所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法包括:A8. The method according to any one of A5 to A7, wherein the target compression algorithm conforming to the compression index parameter and/or the device parameter includes:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

本发明公开了B9、一种压缩存储装置,包括:The present invention discloses B9, a compressed storage device, comprising:

获取模块,用于获取待存储数据的压缩参数,和/或,获取与待存储数据对应的存储设备的设备参数;an acquisition module, used for acquiring compression parameters of the data to be stored, and/or acquiring device parameters of the storage device corresponding to the data to be stored;

选择模块,用于依据所述压缩参数和/或设备参数,选择与所述待存储数据对应的目标压缩方案;以及a selection module, configured to select a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters; and

压缩存储模块,用于利用所述目标压缩方案对所述待存储数据进行压缩存储。A compression storage module, configured to compress and store the data to be stored by using the target compression scheme.

B10、如B9所述的装置,所述压缩参数包括应用场景参数和/或数据库架构参数,则所述选择模块,进一步包括:B10. The device according to B9, wherein the compression parameters include application scenario parameters and/or database architecture parameters, and the selection module further includes:

第一选择子模块,用于从数据库的至少一种存储引擎中选择与所述应用场景参数和/或数据库架构参数对应的目标存储引擎;及a first selection submodule, configured to select a target storage engine corresponding to the application scenario parameters and/or database architecture parameters from at least one storage engine of the database; and

第二选择子模块,用于从所述目标存储引擎的至少一种压缩算法中选择对应的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。The second selection sub-module is configured to select a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, and the target storage engine and its corresponding target compression algorithm constitute the target compression scheme.

B11、如B10所述的装置,所述第一选择子模块,进一步包括:B11. The device according to B10, wherein the first selection submodule further comprises:

第一选择单元,用于在所述应用场景参数为第一应用场景参数时,选择对应的第一存储引擎为目标存储引擎;或者,a first selection unit, configured to select the corresponding first storage engine as the target storage engine when the application scenario parameter is the first application scenario parameter; or,

第二选择单元,用于在所述应用场景参数为第二应用场景参数时,选择对应的第二存储引擎为目标存储引擎;a second selection unit, configured to select the corresponding second storage engine as the target storage engine when the application scenario parameter is the second application scenario parameter;

其中,所述第一应用场景参数包括:联机事务处理场景参数、以及读密集场景参数中的至少一种;Wherein, the first application scenario parameters include: at least one of online transaction processing scenario parameters and read-intensive scenario parameters;

其中,所述第二应用场景参数包括:联机分析处理场景参数、以及批量装载和读密集场景参数中的至少一种。Wherein, the second application scenario parameters include: online analytical processing scenario parameters, and at least one of batch loading and read-intensive scenario parameters.

B12、如B10所述的装置,所述第一选择子模块,进一步包括:B12. The apparatus according to B10, wherein the first selection submodule further comprises:

第三选择单元,用于在所述数据库架构参数为第一数据库架构参数时,选择对应的第三存储引擎为目标存储引擎;或者,a third selection unit, configured to select the corresponding third storage engine as the target storage engine when the database schema parameter is the first database schema parameter; or,

第四选择单元,用于在所述数据库架构参数为第二数据库架构参数时,选择对应的第四存储引擎为目标存储引擎;a fourth selection unit, configured to select the corresponding fourth storage engine as the target storage engine when the database schema parameter is the second database schema parameter;

其中,所述第一数据库架构参数包括:主从架构参数;或者,所述第二数据库架构参数包括:非主从架构参数。Wherein, the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameters include: non-master-slave architecture parameters.

B13、如B9所述的装置,所述压缩参数包括压缩指标参数,则所述选择模块,进一步包括:B13. The device according to B9, wherein the compression parameters include compression index parameters, and the selection module further includes:

第三选择子模块,用于从目标存储引擎的至少一种压缩算法中选择契合所述压缩指标参数和/或所述设备参数的目标压缩算法,所述目标存储引擎及其对应的目标压缩算法组成所述目标压缩方案。A third selection sub-module, configured to select a target compression algorithm that fits the compression index parameter and/or the device parameter from at least one compression algorithm of the target storage engine, the target storage engine and its corresponding target compression algorithm compose the target compression scheme.

B14、如B13所述的装置,所述设备参数包括如下参数中的至少一种:CPU参数、磁盘参数和内存参数。B14. The apparatus according to B13, wherein the device parameters include at least one of the following parameters: a CPU parameter, a disk parameter, and a memory parameter.

B15、如B13所述的装置,所述压缩指标参数包括如下参数中的至少一种:压缩时间参数和压缩比参数。B15. The apparatus according to B13, wherein the compression index parameter includes at least one of the following parameters: a compression time parameter and a compression ratio parameter.

B16、如B13至B15中任一所述的装置,所述契合所述压缩指标参数和/或所述设备参数的目标压缩算法包括:B16. The apparatus according to any one of B13 to B15, wherein the target compression algorithm conforming to the compression index parameter and/or the device parameter includes:

契合第一级压缩指标参数的第一目标压缩算法;或者The first target compression algorithm that fits the first-level compression index parameters; or

契合第二级压缩指标参数的第二目标压缩算法;或者a second-target compression algorithm that fits the parameters of the second-level compression indicator; or

契合第三级压缩指标参数的第三目标压缩算法;其中,所述第一级压缩指标参数、第二级压缩指标参数和第三级压缩指标参数对应的压缩指标递减;或者A third target compression algorithm that conforms to the third-level compression index parameter; wherein the compression index corresponding to the first-level compression index parameter, the second-level compression index parameter, and the third-level compression index parameter decreases; or

契合第一级设备参数的第一目标压缩算法;或者the first target compression algorithm that fits the first-level device parameters; or

契合第二级设备参数的第二目标压缩算法;或者a second-target compression algorithm that fits the second-level device parameters; or

契合第三级设备参数的第三目标压缩算法;其中,所述第一级设备参数、第二级设备参数和第三级设备参数对应的设备性能递减。A third target compression algorithm conforming to the third-level device parameters; wherein, the device performance corresponding to the first-level device parameters, the second-level device parameters, and the third-level device parameters decreases.

Claims (14)

1. A method of compressed storage, comprising:
acquiring compression parameters of data to be stored, and/or acquiring equipment parameters of storage equipment corresponding to the data to be stored;
selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or the equipment parameters;
compressing and storing the data to be stored by utilizing the target compression scheme; if the compression parameters include application scenario parameters and/or database architecture parameters, the step of selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or device parameters further includes:
selecting a target storage engine corresponding to the application scene parameters and/or the database architecture parameters from at least one storage engine of a database;
and selecting a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, wherein the target storage engine and the corresponding target compression algorithm form the target compression scheme.
2. The method of claim 1, wherein the step of selecting the target storage engine corresponding to the application scenario parameter from at least one storage engine of the database further comprises:
if the application scene parameters are first application scene parameters, selecting a corresponding first storage engine as a target storage engine; or,
if the application scene parameters are second application scene parameters, selecting a corresponding second storage engine as a target storage engine;
wherein the first application scene parameter comprises: at least one of an online transaction scenario parameter and a read intensive scenario parameter;
wherein the second application scenario parameter comprises: the on-line analysis processes at least one of scene parameters, and batch load and read intensive scene parameters.
3. The method of claim 1, wherein the step of selecting a target storage engine from at least one storage engine of a database corresponding to the database architecture parameter further comprises:
if the database architecture parameter is a first database architecture parameter, selecting a corresponding third storage engine as a target storage engine; or,
if the database architecture parameter is a second database architecture parameter, selecting a corresponding fourth storage engine as a target storage engine;
wherein the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameter includes: non-master-slave architecture parameters.
4. The method according to claim 1, wherein the compression parameter includes a compression index parameter, and the step of selecting the target compression scheme corresponding to the data to be stored according to the compression parameter and/or the device parameter further includes:
and selecting a target compression algorithm matched with the compression index parameter and/or the equipment parameter from at least one compression algorithm of a target storage engine, wherein the target storage engine and the corresponding target compression algorithm form the target compression scheme.
5. The method of claim 4, wherein the device parameters comprise at least one of: CPU parameters, disk parameters, and memory parameters.
6. The method of claim 4, wherein the compression indicator parameter comprises at least one of: a compression time parameter and a compression ratio parameter.
7. The method according to any one of claims 4 to 6, wherein the target compression algorithm fitting the compression index parameter and/or the device parameter comprises:
a first target compression algorithm fitting the first-stage compression index parameter; or
A second target compression algorithm fitting the second-stage compression index parameter; or
A third target compression algorithm fitting the third-stage compression index parameter; the compression indexes corresponding to the first-stage compression index parameter, the second-stage compression index parameter and the third-stage compression index parameter are decreased progressively; or
A first target compression algorithm fitting the parameters of the first-stage equipment; or
A second target compression algorithm fitting the parameters of the second-stage equipment; or
A third target compression algorithm fitting the third-stage equipment parameters; and the device performance corresponding to the first-stage device parameter, the second-stage device parameter and the third-stage device parameter is decreased progressively.
8. A compressed memory device, comprising:
the acquisition module is used for acquiring compression parameters of data to be stored and/or acquiring device parameters of storage equipment corresponding to the data to be stored;
the selection module is used for selecting a target compression scheme corresponding to the data to be stored according to the compression parameters and/or the equipment parameters; and
the compression storage module is used for compressing and storing the data to be stored by utilizing the target compression scheme; the compression parameters include application scenario parameters and/or database architecture parameters, and the selecting module further includes:
the first selection submodule is used for selecting a target storage engine corresponding to the application scene parameters and/or the database architecture parameters from at least one storage engine of a database; and
and the second selection submodule is used for selecting a corresponding target compression algorithm from at least one compression algorithm of the target storage engine, and the target storage engine and the corresponding target compression algorithm form the target compression scheme.
9. The apparatus of claim 8, wherein the first selection submodule further comprises:
the first selection unit is used for selecting the corresponding first storage engine as a target storage engine when the application scene parameter is the first application scene parameter; or,
the second selection unit is used for selecting the corresponding second storage engine as a target storage engine when the application scene parameters are the second application scene parameters;
wherein the first application scene parameter comprises: at least one of an online transaction scenario parameter and a read intensive scenario parameter;
wherein the second application scenario parameter comprises: the on-line analysis processes at least one of scene parameters, and batch load and read intensive scene parameters.
10. The apparatus of claim 8, wherein the first selection submodule further comprises:
the third selection unit is used for selecting a corresponding third storage engine as a target storage engine when the database architecture parameter is the first database architecture parameter; or,
the fourth selecting unit is used for selecting a corresponding fourth storage engine as a target storage engine when the database architecture parameter is the second database architecture parameter;
wherein the first database architecture parameters include: master-slave architecture parameters; or, the second database architecture parameter includes: non-master-slave architecture parameters.
11. The apparatus of claim 8, wherein the compression parameter comprises a compression index parameter, the selection module further comprising:
and the third selection submodule is used for selecting a target compression algorithm which is matched with the compression index parameter and/or the equipment parameter from at least one compression algorithm of a target storage engine, and the target storage engine and the corresponding target compression algorithm form the target compression scheme.
12. The apparatus of claim 11, wherein the device parameter comprises at least one of: CPU parameters, disk parameters, and memory parameters.
13. The apparatus of claim 11, wherein the compression indicator parameter comprises at least one of: a compression time parameter and a compression ratio parameter.
14. The apparatus according to any one of claims 11 to 13, wherein the target compression algorithm fitting the compression index parameter and/or the device parameter comprises:
a first target compression algorithm fitting the first-stage compression index parameter; or
A second target compression algorithm fitting the second-stage compression index parameter; or
A third target compression algorithm fitting the third-stage compression index parameter; the compression indexes corresponding to the first-stage compression index parameter, the second-stage compression index parameter and the third-stage compression index parameter are decreased progressively; or
A first target compression algorithm fitting the parameters of the first-stage equipment; or
A second target compression algorithm fitting the parameters of the second-stage equipment; or
A third target compression algorithm fitting the third-stage equipment parameters; and the device performance corresponding to the first-stage device parameter, the second-stage device parameter and the third-stage device parameter is decreased progressively.
CN201511000457.3A 2015-12-25 2015-12-25 Compression storage method and device Active CN106919617B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201511000457.3A CN106919617B (en) 2015-12-25 2015-12-25 Compression storage method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201511000457.3A CN106919617B (en) 2015-12-25 2015-12-25 Compression storage method and device

Publications (2)

Publication Number Publication Date
CN106919617A CN106919617A (en) 2017-07-04
CN106919617B true CN106919617B (en) 2020-09-04

Family

ID=59455660

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201511000457.3A Active CN106919617B (en) 2015-12-25 2015-12-25 Compression storage method and device

Country Status (1)

Country Link
CN (1) CN106919617B (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109068183A (en) * 2018-08-08 2018-12-21 湖南快乐阳光互动娱乐传媒有限公司 Live broadcast bullet screen distribution method and device
CN111061722B (en) * 2018-10-16 2023-06-06 阿里巴巴集团控股有限公司 Data compression and data decompression method, device and equipment
CN112770114B (en) * 2020-12-29 2023-03-28 平安普惠企业管理有限公司 Image data compression method and device, computer equipment and storage medium
GB2605795B (en) * 2021-04-13 2023-05-17 British Telecomm Algorithm selection for processor-controlled device
CN116821081A (en) * 2023-07-05 2023-09-29 金篆信科有限责任公司 A method, device, equipment and storage medium for reducing network bandwidth usage of distributed databases

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7177944B1 (en) * 2002-04-13 2007-02-13 Mindspeed Technologies, Inc. Trans-compression selection and configuration in modem over packet networks
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
CN103049561A (en) * 2012-12-31 2013-04-17 华为技术有限公司 Data compressing method, storage engine and storage system
CN103516369A (en) * 2013-06-20 2014-01-15 易乐天 Method and system for self-adaptation data compression and decompression and storage device
CN104462334A (en) * 2014-12-03 2015-03-25 天津南大通用数据技术股份有限公司 Data compression method and device for packing database

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014170984A1 (en) * 2013-04-18 2014-10-23 株式会社日立製作所 Storage system and method for controlling storage

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7177944B1 (en) * 2002-04-13 2007-02-13 Mindspeed Technologies, Inc. Trans-compression selection and configuration in modem over packet networks
CN102761540A (en) * 2012-05-30 2012-10-31 北京奇虎科技有限公司 Data compression method, device and system and server
CN103049561A (en) * 2012-12-31 2013-04-17 华为技术有限公司 Data compressing method, storage engine and storage system
CN103516369A (en) * 2013-06-20 2014-01-15 易乐天 Method and system for self-adaptation data compression and decompression and storage device
CN104462334A (en) * 2014-12-03 2015-03-25 天津南大通用数据技术股份有限公司 Data compression method and device for packing database

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
DWMS中压缩技术的研究与实现;王振玺;《中国优秀硕士学位论文全文数据库》;20110715;I138-398 *

Also Published As

Publication number Publication date
CN106919617A (en) 2017-07-04

Similar Documents

Publication Publication Date Title
CN106919617B (en) Compression storage method and device
US10402420B2 (en) Rule-based extraction, transformation, and loading of data between disparate data sources
US9928113B2 (en) Intelligent compiler for parallel graph processing
CN103366015B (en) A kind of OLAP data based on Hadoop stores and querying method
CN102663114A (en) Database inquiry processing method facing concurrency OLAP (On Line Analytical Processing)
CN102902763B (en) The method of association, retrieving information process data and process information task and device
CN111723161B (en) A data processing method, device and equipment
CN115114293B (en) Database index creation method, related device, equipment and storage medium
CN105653647A (en) Information acquisition method and system of SQL (Structured Query Language) statement
WO2024174305A1 (en) Query processing method and apparatus based on precomputation scenario
US12174848B2 (en) Automated extract, transform, and load process
CN119645534A (en) File processing method, device and computer equipment
CN113886358A (en) Multidimensional modeling analysis method, system, storage medium and electronic device
CN111797284A (en) Method and device for constructing graph database, electronic device, and storage medium
CN113946717B (en) A method, apparatus, device, and storage medium for obtaining subgraph index features
CN113064943A (en) A data acquisition method, device, electronic device and storage medium
CN113448957A (en) Data query method and device
CN107038260B (en) Efficient parallel loading method capable of keeping titan real-time data consistency
Hasan et al. Data transformation from sql to nosql mongodb based on r programming language
CN111949686B (en) Data processing method, device and equipment
US9275103B2 (en) Optimization of JOIN queries for related data
CN114461659B (en) Killing method, device, computer equipment and storage medium
CN118796859A (en) A database access method and device based on MyBatis framework
CN118227618A (en) Data management method and device, electronic equipment and storage medium
CN117171161A (en) Data query method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240115

Address after: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee after: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Address before: 100088 room 112, block D, 28 new street, new street, Xicheng District, Beijing (Desheng Park)

Patentee before: BEIJING QIHOO TECHNOLOGY Co.,Ltd.

Patentee before: Qizhi software (Beijing) Co.,Ltd.

TR01 Transfer of patent right