2016-03-03 142 views
0

可有人请在下面的行为解释Netezza公司:错误:65536:记录大小限制超过

KAP.ADMIN(ADMIN)=> create table char1 (a char(64000),b char(1516)); 

CREATE TABLE 

KAP.ADMIN(ADMIN)=> create table char2 (a char(64000),b char(1517)); 

ERROR: 65536 : Record size limit exceeded

KAP.ADMIN(ADMIN)=> insert into char1 select * from char1; 

ERROR: 65540 : Record size limit exceeded => why this error during insert if create table does not throw any error for same table as shown above.

KAP.ADMIN(ADMIN)=> \d char1 
         Table "CHAR1" 

Attribute |  Type  | Modifier | Default Value 

-----------+------------------+----------+--------------- 

A   | CHARACTER(64000) |   | 

B   | CHARACTER(1516) |   | 

Distributed on hash: "A" 

./nz_ddl_table KAP char1 

Creating table: "CHAR1" 

CREATE TABLE CHAR1 
(
    A  character(64000), 
    B  character(1516) 
) 
DISTRIBUTE ON (A) 
; 

/* 
     Number of columns 2 

    (Variable) Data Size 4 - 65520 
      Row Overhead 28 
    ====================== ============= 

    Total Row Size (bytes) 32 - 65548 

*/ 

我想知道行大小在上述计算案件。 我检查了netezza db用户指南,但无法理解上面例子中的计算。

回答

0

首先根据一行数据创建临时表。

create temp table tmptable as 
select * 
from Table 
limit 1 

然后检查临时表的已用字节数。这应该是每行的大小。

select used_bytes 
from _v_sys_object_storage_size a inner join 
_v_table b 
on a.tblid = b.objid 
and b.tablename = 'tmptable' 

Netezza公司有一定的局限性: 1)在字符/ varchar字段的最大字符数:64000 2)的最大行大小:65,535字节

超越65千个字节是不可能的记录长度在新西兰。 虽然新西兰盒子提供了巨大的空间,但用准确的空间预测而不是随意间距来移动是个好主意。现在,在您的要求中,所有属性都会强制要求使用char(64000),或者可以使用实时数据分析进行压缩。如果可以进一步压缩,则重新访问属性长度。 同样在这样的需求中,永远不要插入到char1 select * .......语句中,因为这将允许系统选择首选的数据类型,并且可能不需要更高的大小调整结束。

0

我觉得这个环节做了解释Netezza公司/ PDA数据类型的头顶一个良好的工作:

For every row of every table, there is a 24-byte fixed overhead of the rowid, createxid, and deletexid. If you have any nullable columns, a null vector is required and it is N/8 bytes where N is the number of columns in the record. 
The system rounds up the size of 
this header to a multiple of 4 bytes. 
In addition, the system adds a record header of 4 bytes if any of the following is true: 

Column of type VARCHAR 
Column of type CHAR where the length is greater than 16 (stored internally as VARCHAR) 
Column of type NCHAR 
Column of type NVARCHAR 

Using UTF-8 encoding, each Unicode code point can require 1 - 4 bytes of storage. A 10-character string requires 10 bytes of storage if it is ASCII and up to 20 bytes if it is Latin, or as many as 40 bytes if it is Kanji. 

The only time a record does not contain a header is if all the columns are defined as NOT NULL, there are no character data types larger than 16 bytes, and no variable character data types. 

https://www.ibm.com/support/knowledgecenter/SSULQD_7.2.1/com.ibm.nz.dbu.doc/c_dbuser_data_types_calculate_row_size.html