search
HomeDatabaseMysql TutorialDB2 10.5列式表存储技术

DB2 10.5引入列式存储表技术,作为DW数据应用的特性,对性能具有很大的提升,同时对SQL基本不做索引优化,查询时直接可以按照列存

DB2 10.5引入列式存储表技术,作为DW数据应用的特性,对性能具有很大的提升,同时对SQL基本不做索引优化,查询时直接可以按照列存储格式查询相关列即可,可以说管理很简单了。作为一个新特性,DB2 LUW V10.5的列式组织表功能依然作为一个可选择功能项,,用户可以按照自己数据库业务的特点,选择是否启用该功能,对于升级到DB2 LUW V10.5的数据库环境来说,需要经过同样的参数配置,也可以支持这个功能。

在创建数据库前,在DB2 V10.5实例提供了注册变量选项值,即DB2_WORK_LOAD新增可配置值ANALYTICS,配置改参数值后,DB2会为新创建的分析性工作负载数据库建立最佳缺省配置,启用改参数后,数据库会自动配置如下参数,也是支持和影响列式存储环境的几个关键参数:

dft_table_org该参数指定创建表的默认类型,通常设定为row,启用ANALYTICS注册变量值后,系统会自动配置为column

dft_degree 指定分区内SQL语句的并行度,该参数会被自动配置为any

dft_extent_sz 缺省表空间的扩张块大小,该参数会自动被设置为4(默认值为32)

catalogcache_sz 即目录高速缓存,该参数会被自动设置为比通常数据库类型的默认值更大的值

util_heap_sz 即实用程序堆大小,该参数会被自动配置为一个用于装载列组织表时所需额外内存的大小

auto_reorg  即自动重组操作,该参数会被配置为on

sortheap(排序堆)和sheapthres_shr需要根据实际计算配置

 

当然,如果在已经创建好的数据库库后才对DB2_WORK_LOAD注册变量参数配置analytics,当数据库运行autoconfigure也具有相同效果

 

创建列组织表

 

那么如何创建DB2列组织表呢?其实创建列组织表和创建普通行式组织表的语句大体相同,只是列式组织表在creat table后添加了ORGANIZE BY  COLUMN的语句。当然如果你当前的数据库级的配置参数dft_table_org设置为column的话,也可以不使用organize by column语句选项,因为在启用该参数值的数据库中,创建的表默认就是列组织表类型,如下是一个创建列组织表的示例DDL:

CREATE TABLE "DB2INST1"."EMPLOYEE" (
                "EMPNO" CHAR(6 OCTETS) NOT NULL ,
                "FIRSTNME" VARCHAR(12 OCTETS) NOT NULL ,
                "MIDINIT" CHAR(1 OCTETS) ,
                "LASTNAME" VARCHAR(15 OCTETS) NOT NULL ,
                "WORKDEPT" CHAR(3 OCTETS) ,
                "PHONENO" CHAR(4 OCTETS) ,
                "HIREDATE" DATE ,
                "JOB" CHAR(8 OCTETS) ,
                "EDLEVEL" SMALLINT NOT NULL ,
                "SEX" CHAR(1 OCTETS) ,
                "BIRTHDATE" DATE ,
                "SALARY" DECIMAL(9,2) ,
                "BONUS" DECIMAL(9,2) ,
                "COMM" DECIMAL(9,2) )
                IN "USERSPACE1"
                ORGANIZE BY  COLUMN;

行组织表与列组织表的转换

那么对于创建时没有指定列式组织或者由低版本升级的数据库中的行式组织表,如何将其转换成列式组织表呢?DB2 V10.5充分考虑了用户需求,提供了一个新的实用程序工具db2convert,用于将行式组织表转换为列式组织表,如下依然以db2inst2.employee表为例,将其转换为列式组织表,获取到的原始表的DDL语句如下:

CREATE TABLE"DB2INST2"."EMPLOYEE"  (
                "EMPNO" CHAR(6 OCTETS) NOT NULL ,
                "FIRSTNME" VARCHAR(12 OCTETS) NOT NULL ,
                "MIDINIT" CHAR(1 OCTETS) ,
                "LASTNAME" VARCHAR(15 OCTETS) NOT NULL ,
                "WORKDEPT" CHAR(3 OCTETS) ,
                "PHONENO" CHAR(4 OCTETS) ,
                "HIREDATE" DATE ,
                "JOB" CHAR(8 OCTETS) ,
                "EDLEVEL" SMALLINT NOT NULL ,
                "SEX" CHAR(1 OCTETS) ,
                "BIRTHDATE" DATE ,
                "SALARY" DECIMAL(9,2) ,
                "BONUS" DECIMAL(9,2) ,
                "COMM" DECIMAL(9,2) )
                IN "USERSPACE1"
                ORGANIZE BY ROW;

为了便于观察过程,我们最好为其导入数据,有一定的数据量,以便于观察转换过程,此测试数据来源都是DB2示例数据库sample中相关表中获取的,在此就不多讲,读者可以自己自行测试效果。

如此,我们就可以对其进行转换,其实db2convert工具的用法相对简单,可以进行整库转换,也可以指定单表,需要提供表的schema和tablename,具体用法可以参阅相关使用说明:

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
How does MySQL index cardinality affect query performance?How does MySQL index cardinality affect query performance?Apr 14, 2025 am 12:18 AM

MySQL index cardinality has a significant impact on query performance: 1. High cardinality index can more effectively narrow the data range and improve query efficiency; 2. Low cardinality index may lead to full table scanning and reduce query performance; 3. In joint index, high cardinality sequences should be placed in front to optimize query.

MySQL: Resources and Tutorials for New UsersMySQL: Resources and Tutorials for New UsersApr 14, 2025 am 12:16 AM

The MySQL learning path includes basic knowledge, core concepts, usage examples, and optimization techniques. 1) Understand basic concepts such as tables, rows, columns, and SQL queries. 2) Learn the definition, working principles and advantages of MySQL. 3) Master basic CRUD operations and advanced usage, such as indexes and stored procedures. 4) Familiar with common error debugging and performance optimization suggestions, such as rational use of indexes and optimization queries. Through these steps, you will have a full grasp of the use and optimization of MySQL.

Real-World MySQL: Examples and Use CasesReal-World MySQL: Examples and Use CasesApr 14, 2025 am 12:15 AM

MySQL's real-world applications include basic database design and complex query optimization. 1) Basic usage: used to store and manage user data, such as inserting, querying, updating and deleting user information. 2) Advanced usage: Handle complex business logic, such as order and inventory management of e-commerce platforms. 3) Performance optimization: Improve performance by rationally using indexes, partition tables and query caches.

SQL Commands in MySQL: Practical ExamplesSQL Commands in MySQL: Practical ExamplesApr 14, 2025 am 12:09 AM

SQL commands in MySQL can be divided into categories such as DDL, DML, DQL, DCL, etc., and are used to create, modify, delete databases and tables, insert, update, delete data, and perform complex query operations. 1. Basic usage includes CREATETABLE creation table, INSERTINTO insert data, and SELECT query data. 2. Advanced usage involves JOIN for table joins, subqueries and GROUPBY for data aggregation. 3. Common errors such as syntax errors, data type mismatch and permission problems can be debugged through syntax checking, data type conversion and permission management. 4. Performance optimization suggestions include using indexes, avoiding full table scanning, optimizing JOIN operations and using transactions to ensure data consistency.

How does InnoDB handle ACID compliance?How does InnoDB handle ACID compliance?Apr 14, 2025 am 12:03 AM

InnoDB achieves atomicity through undolog, consistency and isolation through locking mechanism and MVCC, and persistence through redolog. 1) Atomicity: Use undolog to record the original data to ensure that the transaction can be rolled back. 2) Consistency: Ensure the data consistency through row-level locking and MVCC. 3) Isolation: Supports multiple isolation levels, and REPEATABLEREAD is used by default. 4) Persistence: Use redolog to record modifications to ensure that data is saved for a long time.

MySQL's Place: Databases and ProgrammingMySQL's Place: Databases and ProgrammingApr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL: From Small Businesses to Large EnterprisesMySQL: From Small Businesses to Large EnterprisesApr 13, 2025 am 12:17 AM

MySQL is suitable for small and large enterprises. 1) Small businesses can use MySQL for basic data management, such as storing customer information. 2) Large enterprises can use MySQL to process massive data and complex business logic to optimize query performance and transaction processing.

What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?What are phantom reads and how does InnoDB prevent them (Next-Key Locking)?Apr 13, 2025 am 12:16 AM

InnoDB effectively prevents phantom reading through Next-KeyLocking mechanism. 1) Next-KeyLocking combines row lock and gap lock to lock records and their gaps to prevent new records from being inserted. 2) In practical applications, by optimizing query and adjusting isolation levels, lock competition can be reduced and concurrency performance can be improved.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment