zoukankan      html  css  js  c++  java
  • PPAS可以安装分区表

    磨砺技术珠矶,践行数据之道,追求卓越价值 

    回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页

    [作者 高健@博客园  luckyjackgao@gmail.com]

    在PostgreSQL中,分区表是无法建立的,或者说是假的分区表。

    步骤通常如下:

    建立base表,建立继承base表的各个子表,为base表建立rule,建立trigger。

    这样,把base表当作分区表的入口,由于insert/update时不断触发trigger,其效率还是很低下的。

    可以参见

    https://wiki.postgresql.org/wiki/Table_partitioning

    http://www.postgresql.org/docs/current/interactive/ddl-partitioning.html

    查询的时候,optimizer 到达子表是没有问题的。

    Currently we allow the user to create arbitrary nested tables with arbitrary constraints and then the planner tries to detect at run-time which child tables are candidates for the query. See PostgreSQL Partitioning for details.

    也可以参考:

    http://blog.csdn.net/beiigang/article/details/9056263

    http://pgpen.blogspot.com/2013_05_01_archive.html

    在PPAS9.0里,建立分区表仍然是一个比较痛苦的工作。

    但是PPAS9.1和PPAS9.2里面,带有直接建立分区表的功能,使用起来更方便了:

    例如:

    edb=# drop table employees cascade;
    DROP TABLE
    edb=# 
    edb=# create table employees
    edb-# ( empno integer,
    edb(#   ename varchar(10),
    edb(#   job varchar(9),
    edb(# PRIMARY KEY (empno)
    edb(# )
    edb-# partition by list (job)
    edb-# ( partition emp_mgmt values ('manager'),
    edb(#   partition emp_sales values ('salesman'),
    edb(#   partition emp_ops values ('clerk')
    edb(# );
    CREATE TABLE
    edb=# dt 
                             
       schema     |           name            |  type    |    owner    
    --------------+---------------------------+----------+--------------
     enterprisedb | employees                 | テーブル   | enterprisedb
     enterprisedb | employees_emp_mgmt        | テーブル   | enterprisedb
     enterprisedb | employees_emp_ops         | テーブル   | enterprisedb
     enterprisedb | employees_emp_sales       | テーブル   | enterprisedb
     ...
    (21 rows)
    
    edb=# 

    再看index的状态,那是非常有趣的。

     

    edb=# di
                                            
       schema     |           name           | type      |    owner     |         table         
    --------------+--------------------------+----- -----+--------------+--------------------------
     enterprisedb | employees_emp_mgmt_pkey  | index     | enterprisedb | employees_emp_mgmt
     enterprisedb | employees_emp_ops_pkey   | index     | enterprisedb | employees_emp_ops
     enterprisedb | employees_emp_sales_pkey | index     | enterprisedb | employees_emp_sales
     enterprisedb | employees_pkey           | index     | enterprisedb | employees
     ...
    (18 rowa)
    
    edb=# 

     

    而如果在postgresql里建立分区表,涉及到index就很麻烦了:postgresql不支持跨越表的索引。

    http://www.linuxforu.com/2012/01/partitioning-in-postgresql/

     

    [作者 高健@博客园  luckyjackgao@gmail.com]

    回到上一级页面: PostgreSQL基础知识与基本操作索引页     回到顶级页面:PostgreSQL索引页 

    磨砺技术珠矶,践行数据之道,追求卓越价值  

  • 相关阅读:
    使用Hibernate实现简单的增、改、删、查操作
    Hibernate 配置
    Win7/8下Oracle的安装
    Android从相册获取图片
    Android图片缓存分析(一)
    TextView淡入淡出效果
    Android动画全解
    ListView的getChildAt(i)方法
    AIDL小记
    自定义SeekBar的Thumb不对齐的解决方法。
  • 原文地址:https://www.cnblogs.com/gaojian/p/3271980.html
Copyright © 2011-2022 走看看