Home Database Mysql Tutorial SQL SERVER 2008的数据压缩

SQL SERVER 2008的数据压缩

Jun 07, 2016 pm 03:06 PM
server sql compression data Version

一、 数据 库版本 数据 压缩 在Sql Server 2008上才支持,2005不行,并且还要是企业版。我常常忘了这一点,在2005的Studio上闹出语法错误的状况,折腾浪费了好一阵才醒悟过来。 二、 压缩 状况 大约可以节省20%-50%的空间,并且行 压缩 和页 压缩 有所区别。


一、数据库版本
数据压缩在Sql Server 2008上才支持,2005不行,并且还要是企业版。我常常忘了这一点,在2005的Studio上闹出语法错误的状况,折腾浪费了好一阵才醒悟过来。


二、压缩状况
大约可以节省20%-50%的空间,并且行压缩和页压缩有所区别。
但让我失望的是,像含有Varchar(max),xml这种字段类型的,反而似乎压缩不起什么作用。其实我觉得最需要压缩的就是它们。


三、行压缩与页压缩
压缩是将固定长度类型存储为可变长度存储类型。页压缩除了行压缩,还有字典压缩等等。就是说,页级比行级压得更狠,更厉害。通常,表的话我采用页压缩;索引,行压缩。不为什么,想当然耳。


四、开始压缩
压缩的时候,硬盘要有空余的空间,因为压缩需要消耗额外的磁盘。比如说,我压缩一个190GB的表,大概还要额外占用90GB的空间。压缩完了以后,可以通过收缩数据库文件释放。释放了以后空间就连本带利多上一点。


非分区表页级压缩
ALTER TABLE [table1] REBUILD WITH (DATA_COMPRESSION = PAGE);
GO


分区表页级压缩
ALTER TABLE [partitiontable1]
REBUILD PARTITION = ALL
WITH
(
DATA_COMPRESSION = PAGE ON PARTITIONS(1 TO 11)
);
GO


非分区索引行级压缩
ALTER INDEX ix_id
ON table1
REBUILD WITH ( DATA_COMPRESSION = ROW ) ;
GO

分区索引行级压缩
ALTER INDEX Ix_Id ON partitiontable1
REBUILD PARTITION = ALL
WITH
(
DATA_COMPRESSION = ROW ON PARTITIONS(1 TO 16)
);
GO


五、压缩以后收缩数据库文件
DBCC SHRINKFILE ([数据库文件逻辑名], 收缩至多大(以M为单位));
GO


DBCC SHRINKFILE ([data_0], 5371);
GO


这个收缩后大小,我是先在Studio中,选中数据库,鼠标右键,在菜单中选任务,收缩,然后得到这个收缩后的最小尺寸,再抄到脚本上的。
其实帮助里面说,DBCC SHRINKFILE 不会将文件收缩到小于存储文件中的数据所需要的大小。例如,如果使用 10 MB 数据文件中的 7 MB,则带有 target_size 为 6 的 DBCC SHRINKFILE 语句只能将该文件收缩到 7 MB,而不能收缩到 6 MB。那么我们将5371写成1,岂不快哉?我没有试,可能可以。


六、经验总结
压缩和收缩分区表、分区索引消耗好多时间。有个几十G的分区表,我压缩完了以后,收缩花了2天又19个小时,是用脚本执行的,一口气不停歇。
非分区表则很快,100多G的文件,1、2小时就搞定了。


七、为什么要压缩
我觉得数据库服务器的瓶颈往往在于硬盘。象我们的服务器,8个核,平常时CPU很少上到10%,到30%已经顶天了。压缩的意义,就是将硬盘的压力转一部分到CPU,正中下怀。
另一个就是,现在我们网站功能逐渐多了以后,数据增长也很快。几年下来,数据积累相当可观,现在已经用了600多G了。

 

八、不要用操作系统的文件压缩

不要去使用只读用户定义文件组和只读数据库的 NTFS 压缩。结果没有压缩多少,反倒是想将数据库只读去掉,还要先解压。死未?

Statement of this Website
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

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)
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Open source! Beyond ZoeDepth! DepthFM: Fast and accurate monocular depth estimation! Apr 03, 2024 pm 12:04 PM

0.What does this article do? We propose DepthFM: a versatile and fast state-of-the-art generative monocular depth estimation model. In addition to traditional depth estimation tasks, DepthFM also demonstrates state-of-the-art capabilities in downstream tasks such as depth inpainting. DepthFM is efficient and can synthesize depth maps within a few inference steps. Let’s read about this work together ~ 1. Paper information title: DepthFM: FastMonocularDepthEstimationwithFlowMatching Author: MingGui, JohannesS.Fischer, UlrichPrestel, PingchuanMa, Dmytr

Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Google is ecstatic: JAX performance surpasses Pytorch and TensorFlow! It may become the fastest choice for GPU inference training Apr 01, 2024 pm 07:46 PM

The performance of JAX, promoted by Google, has surpassed that of Pytorch and TensorFlow in recent benchmark tests, ranking first in 7 indicators. And the test was not done on the TPU with the best JAX performance. Although among developers, Pytorch is still more popular than Tensorflow. But in the future, perhaps more large models will be trained and run based on the JAX platform. Models Recently, the Keras team benchmarked three backends (TensorFlow, JAX, PyTorch) with the native PyTorch implementation and Keras2 with TensorFlow. First, they select a set of mainstream

Slow Cellular Data Internet Speeds on iPhone: Fixes Slow Cellular Data Internet Speeds on iPhone: Fixes May 03, 2024 pm 09:01 PM

Facing lag, slow mobile data connection on iPhone? Typically, the strength of cellular internet on your phone depends on several factors such as region, cellular network type, roaming type, etc. There are some things you can do to get a faster, more reliable cellular Internet connection. Fix 1 – Force Restart iPhone Sometimes, force restarting your device just resets a lot of things, including the cellular connection. Step 1 – Just press the volume up key once and release. Next, press the Volume Down key and release it again. Step 2 – The next part of the process is to hold the button on the right side. Let the iPhone finish restarting. Enable cellular data and check network speed. Check again Fix 2 – Change data mode While 5G offers better network speeds, it works better when the signal is weaker

7-zip maximum compression rate setting, how to compress 7zip to the minimum 7-zip maximum compression rate setting, how to compress 7zip to the minimum Jun 18, 2024 pm 06:12 PM

I found that the compressed package downloaded from a download website will be larger than the original compressed package after decompression. The difference is tens of Kb for a small one and several dozen Mb for a large one. If it is uploaded to a cloud disk or paid space, it does not matter if the file is small. , if there are many files, the storage cost will be greatly increased. I studied it specifically and can learn from it if necessary. Compression level: 9-Extreme compression Dictionary size: 256 or 384, the more compressed the dictionary, the slower it is. The compression rate difference is larger before 256MB, and there is no difference in compression rate after 384MB. Word size: maximum 273 Parameters: f=BCJ2, test and add parameter compression rate will be higher

750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth 750,000 rounds of one-on-one battle between large models, GPT-4 won the championship, and Llama 3 ranked fifth Apr 23, 2024 pm 03:28 PM

Regarding Llama3, new test results have been released - the large model evaluation community LMSYS released a large model ranking list. Llama3 ranked fifth, and tied for first place with GPT-4 in the English category. The picture is different from other benchmarks. This list is based on one-on-one battles between models, and the evaluators from all over the network make their own propositions and scores. In the end, Llama3 ranked fifth on the list, followed by three different versions of GPT-4 and Claude3 Super Cup Opus. In the English single list, Llama3 overtook Claude and tied with GPT-4. Regarding this result, Meta’s chief scientist LeCun was very happy and forwarded the tweet and

The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks The vitality of super intelligence awakens! But with the arrival of self-updating AI, mothers no longer have to worry about data bottlenecks Apr 29, 2024 pm 06:55 PM

I cry to death. The world is madly building big models. The data on the Internet is not enough. It is not enough at all. The training model looks like "The Hunger Games", and AI researchers around the world are worrying about how to feed these data voracious eaters. This problem is particularly prominent in multi-modal tasks. At a time when nothing could be done, a start-up team from the Department of Renmin University of China used its own new model to become the first in China to make "model-generated data feed itself" a reality. Moreover, it is a two-pronged approach on the understanding side and the generation side. Both sides can generate high-quality, multi-modal new data and provide data feedback to the model itself. What is a model? Awaker 1.0, a large multi-modal model that just appeared on the Zhongguancun Forum. Who is the team? Sophon engine. Founded by Gao Yizhao, a doctoral student at Renmin University’s Hillhouse School of Artificial Intelligence.

Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! Tesla robots work in factories, Musk: The degree of freedom of hands will reach 22 this year! May 06, 2024 pm 04:13 PM

The latest video of Tesla's robot Optimus is released, and it can already work in the factory. At normal speed, it sorts batteries (Tesla's 4680 batteries) like this: The official also released what it looks like at 20x speed - on a small "workstation", picking and picking and picking: This time it is released One of the highlights of the video is that Optimus completes this work in the factory, completely autonomously, without human intervention throughout the process. And from the perspective of Optimus, it can also pick up and place the crooked battery, focusing on automatic error correction: Regarding Optimus's hand, NVIDIA scientist Jim Fan gave a high evaluation: Optimus's hand is the world's five-fingered robot. One of the most dexterous. Its hands are not only tactile

See all articles