关于 SQL Server压缩 的故事,最早是从SQL Server 2005开始的,在企业版和开发版中增加了一种叫做vardecimal的新存储格式,这个表级的选项会影响到decimal和numeric字段。当对值的精度要求低于字段可用精度,如在一个decimal(18,9)类型的字段中存储1.5这个数
关于SQL Server压缩的故事,最早是从SQL Server 2005开始的,在企业版和开发版中增加了一种叫做vardecimal的新存储格式,这个表级的选项会影响到decimal和numeric字段。当对值的精度要求低于字段可用精度,如在一个decimal(18,9)类型的字段中存储1.5这个数值时,存储上就需要有相应的压缩。从效果上来看,它就是一个varchar类型的数字型版本。
SQL Server 2008所包含的已远不止这些小技巧,Chad Boyd写到 :
以下是引用片段: 无论从哪方面来看,SQL Server 2008的数据压缩都与现在有着巨大的差异(尽管它依然支持或者说包括vardecimal类型)――引起这种差异的真像是,如果你对一个给定的table/index启用压缩功能,那么底层的row/page格式将不再相同――是的,就是这样,你听得没错――如果你使用压缩(ROW或者PAGE),那么SQL 2008的row/page格式将不同于现有的格式(如果你只是在table/index上使用压缩的话)。因此,在SQL 2008中,有两种,没错,是两种可选row/page数据格式。你现在可能会想知道“那么,如果row/page格式改变了,那你们究竟是如何在这么短的时间内,依然有足够的时间去重新生成SQL Server所有需要识别这些格式的组件的呢?”答案就是我们不需要那样做――因为Storage Engine是SQL 2008中唯一一个需要知道新的row/page格式的组件。 |
行级压缩将大幅减少元数据所需的变量长度,较以前每个字段需要花费2个字节来存储,现在只要仅仅3个位。字段本身现在也变得更小,在整型字段中存储像1这样的数值,只需要一个字节,而大数值则最多只需要4个字节。
行级压缩则允许在行间共享共有数据。Chad首先谈到的两种技术就是列前缀和页字典:
假设你在一页的数据行中有一列数据有这些值:‘Chad’、‘Chadwick’、‘Chadly’、‘Chad’、‘Chadster’、‘Chadwick’和‘Chadly’(故意重复的数值)――正如你所见,有相当多的冗余‘前缀’数据在这一页的同一列的不同行中,是吧?因此,你最终可能会想到这样的一个场景:将列的前缀‘Chad’存储在CI结构中,每一个列的最后都指向这个前缀值,最后出现在磁盘上的值会像这样:‘’,‘1wick’,‘1ly’,‘1ster’,‘1wick’和‘1ly’。
所以,对于上述例子中的含有Chad的同列数值,在经过对“列前缀”值进行计算和存储后,你可能得到一个会含有如‘1ly’和‘1wick’这些值的页字典,而真正行内数值则极有可能看上去像这样:‘’、‘2’、‘3’、‘’、‘1ster’、‘3’和‘2’。通过这种方式,我们让原本需要大约25个字节来存储的行数据,减少到只要大约17个字节来存储,节省30%以上。
每一个页都是单独压缩的,前缀和字典也存储在页内。由于页是存储分配的原子单位,将半页压缩到四分之一页是没有任何意义的,所以,只有在页的内容快满的时候才会开始压缩处理。
在使用行和页压缩时还有一个性能权衡问题,因为CPU使用率会上升,但I/O使用率和内存占用会下降。
Backup Compression是2008的另一个特性,它是通过普通的文件系统型压缩技术实现的,对于给定的数据库,只有启用或者禁用,没有其它可调节选项。
尽管非企业版服务器可以恢复带压缩的备份,但这所有的压缩选项极有可能成为企业版专享选项。
查看英文原文:New Compression Features in SQL Server 2008
精彩推荐
|
SQL Server 2008 功能、特性介绍 |

InnoDB uses redologs and undologs to ensure data consistency and reliability. 1.redologs record data page modification to ensure crash recovery and transaction persistence. 2.undologs records the original data value and supports transaction rollback and MVCC.

Key metrics for EXPLAIN commands include type, key, rows, and Extra. 1) The type reflects the access type of the query. The higher the value, the higher the efficiency, such as const is better than ALL. 2) The key displays the index used, and NULL indicates no index. 3) rows estimates the number of scanned rows, affecting query performance. 4) Extra provides additional information, such as Usingfilesort prompts that it needs to be optimized.

Usingtemporary indicates that the need to create temporary tables in MySQL queries, which are commonly found in ORDERBY using DISTINCT, GROUPBY, or non-indexed columns. You can avoid the occurrence of indexes and rewrite queries and improve query performance. Specifically, when Usingtemporary appears in EXPLAIN output, it means that MySQL needs to create temporary tables to handle queries. This usually occurs when: 1) deduplication or grouping when using DISTINCT or GROUPBY; 2) sort when ORDERBY contains non-index columns; 3) use complex subquery or join operations. Optimization methods include: 1) ORDERBY and GROUPB

MySQL/InnoDB supports four transaction isolation levels: ReadUncommitted, ReadCommitted, RepeatableRead and Serializable. 1.ReadUncommitted allows reading of uncommitted data, which may cause dirty reading. 2. ReadCommitted avoids dirty reading, but non-repeatable reading may occur. 3.RepeatableRead is the default level, avoiding dirty reading and non-repeatable reading, but phantom reading may occur. 4. Serializable avoids all concurrency problems but reduces concurrency. Choosing the appropriate isolation level requires balancing data consistency and performance requirements.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.

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.

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.

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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver Mac version
Visual web development tools

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.

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.