Versioned table in Netezza
Problem
One QC process need to obtain tables and their row counts in a database in Netezza. We use the below SQL query to do so:
SELECT CAST(TRIM(RELNAME) AS VARCHAR(50)) TABLE_NAME, CAST(CASE WHEN RELTUPLES < 0 THEN ((2^32) * RELREFS) + ((2^32) + RELTUPLES ) ELSE ((2^32) * RELREFS) + ( RELTUPLES ) END AS BIGINT) NUM_ROWS FROM _T_CLASS ,_T_OBJECT WHERE _T_OBJECT.OBJID =_T_CLASS.OID AND _T_OBJECT.OBJCLASS = 4905;
Now oneday an issue occurs, we add a column to one table, but this query output will not include the altered table.
Solution
This issue pushes us to look into the query and the system tables. After making research, the more internally principle of Netezza is gradually discovered.
In Netezza database system, it will use ids(a number) to represent objects(tables, views, stored procedures...) internally. For tables, it will use id 4905 to represent.
SELECT * FROM _T_OBJECT WHERE OBJCLASS = 4905;
When a table structure is modified, for example, add/modify/delete a column, the Netezza system will internally use a different id for the altered table, which is 4961, and the table is called versioned table now.
We could use system view to check whether there is versioned tables in the database:
SELECT * FROM _V_SYS_TABLE_VERSION_OBJECT_DEFN;
And Here is some explanation of versioned table:
Versioned tables come about as a result of doing an alter table. This results in multiple data stores for the table. When you go to query the table, Netezza must recombine the separate data stores back into a single entity. This action will be performed automatically and on-the-fly. But it does result in additional performance cost for using the UNION ALL view instead of having all of the data exist in a single table.Therefore, it is a best practice to reconstitute the table by using:
GROOM TABLE <tablename> VERSIONS;
And after the groom sql is executed, the id is set back to 4905 for the table.
So as a result of versioned table, it's better to modify the where statement in QC script to:
WHERE _T_OBJECT.OBJID =_T_CLASS.OID AND _T_OBJECT.OBJCLASS IN (4905,4961)
In this way, the query will give expected result even if there is altered table. But again it is suggested to apply the groom clause reasonably soon after table is altered.
(EnD)
Related articles
http://netezza-dba.blogspot.com/2014/06/netezza-versioned-tables.html
Versioned table in Netezza的更多相关文章
- Data import/export of Netezza using external table
Introduction External table is a special table in Netezza system, which could be used to import/exp ...
- Netezza External Tables --How to use local files in external table
FROM: http://tennysusantobi.blogspot.com/2012/08/netezza-external-tables.html Netezza External Table ...
- 13.1.17 CREATE TABLE Syntax
13.1.17 CREATE TABLE Syntax 13.1.17.1 CREATE TABLE ... LIKE Syntax 13.1.17.2 CREATE TABLE ... SELECT ...
- 散列表(hash table)——算法导论(13)
1. 引言 许多应用都需要动态集合结构,它至少需要支持Insert,search和delete字典操作.散列表(hash table)是实现字典操作的一种有效的数据结构. 2. 直接寻址表 在介绍散列 ...
- React使用antd Table生成层级多选组件
一.需求 用户对不同的应用需要有不同的权限,用户一般和角色关联在一起,新建角色的时候会选择该角色对应的应用,然后对应用分配权限.于是写了一种实现的方式.首先应用是一个二级树,一级表示的是应用分组,二级 ...
- 创建几个常用table展示方式插件
这次和大家分享的是自己写的一个table常用几种展示格式的js插件取名为(table-shenniu),样式使用的是bootstrap.min.css,还需要引用jquery.min.js包,这个插件 ...
- html中table边框属性
1.向右(横向)合并: <td colspan="5"><span>后台管理系统</span></td> 2.向下(纵向)合并: & ...
- MySQL中You can't specify target table for update in FROM clause一场
mysql中You can't specify target table <tbl> for update in FROM clause错误的意思是说,不能先select出同一表中的某些值 ...
- 打印Lua的Table对象
小伙伴们再也不用为打印lua的Table对象而苦恼了, 本人曾也苦恼过,哈哈 不过今天刚完成了这个东西, 以前在网上搜过打印table的脚本,但是都感觉很不理想,于是,自己造轮子了~ 打印的效果,自己 ...
随机推荐
- XData -–无需开发、基于配置的数据库RESTful服务,可作为移动App和ExtJS、WPF/Silverlight、Ajax等应用的服务端
XData -–无需开发.基于配置的数据库RESTful服务,可作为移动App和ExtJS.WPF/Silverlight.Ajax等应用的服务端 源起一个App项目,Web服务器就一台,已经装了 ...
- Django RedirectView
RedirectView作用是重定向一个指定,给定的Url.这个给定的Url可能包含有字典风格的字符串,因为关键字(词)会被改变,所以从这个Url中捕获的参数可能也会被修改,例如,Url中的“%”应该 ...
- Java Docs
1 Java Docs on Oracle: 1.1 Online(EN): JavaSE6 http://docs.oracle.com/javase/6/docs/api/index.htm ...
- LPC2478_调试心得(转)
1.在调试“E:\htwang\smart2200v201\ARM嵌入式系统实验教程(二)\开发板出厂编程程序\液晶显示程序\LCM_Disp”的程序时,想使用外部RAM进行仿真调试,在将ADS1.2 ...
- where 子句中使用通配符
模糊匹配 ------------------------模糊匹配----------------- '[1-9]'.'[a-z]'.'[^4]' select * from student wher ...
- 将声音文件加入VC
概述 VC++是微软公司开发的一个IDE(集成开发环境),换句话说,就是使用c++的一个开发平台.有些软件就是这个编出来的...另外还有VB,VF.只是使用不同语言...但是,VC++是Windows ...
- Spark Streaming中动态Batch Size实现初探
本期内容 : BatchDuration与 Process Time 动态Batch Size Spark Streaming中有很多算子,是否每一个算子都是预期中的类似线性规律的时间消耗呢? 例如: ...
- IIS7 IIS8 中多个版本php共存的方法
原文地址: https://blog.cozof.com/pieces/54.shtml 最近又重回.net,用回IIS.然后用到某个php开源项目,需要低版本的php,之前装的一个php5.5不能用 ...
- python常用库
本文由 伯乐在线 - 艾凌风 翻译,Namco 校稿.未经许可,禁止转载!英文出处:vinta.欢迎加入翻译组. Awesome Python ,这又是一个 Awesome XXX 系列的资源整理,由 ...
- iOS 获取应用版本信息
现在许多接口都需要上传应用版本信息,所以呢,这个是必不可少的,可以在进入应用的时候先获取到,然后存在单例中,用的时候直接调用单例就好了,记住这些字符串 NSString *executableFile ...