postgresql – 数据库归档解决方案
继续我在
Is it a good idea to move high-volume and highly-accessed tables to a separate database?发布的问题,我正在寻找可用于PostgreSQL中数据库归档的不同技术/解决方案.
我能想到的几个解决方案是: >表分区 任何其他建议/指针/解决方案真的很受欢迎和赞赏. 注意:我们在CentOS5.2上运行PostgreSQL v9.1.3
我对存档的建议:
>创建archive_tablespace(如果您希望在归档时可以分离硬件) create table posts_all ( LIKE public.posts) ; create table posts_archive () inherits ( public.posts_all) ; alter table public.posts inherits ( public.posts_all ) ; 之后我们将有2个新表:public.posts_all(在帖子中使用相同的列)查询所有帖子(存档和生产)和public.posts_archive查询所有存档帖子. Public.posts将继承自posts_all. create table archive_2005.posts ( check(record_date >= '2005-01-01 00:00:00'::timestamp and record_date < '2006-01-01 00:00:00'::timestamp) ) inherits (posts_archive) tablespace archive_tablesapce; 之后,您将在schema archive_2005中拥有新的表帖子,postgresql planer将知道该数据仅在设计的时间段内.如果您通过另一个时间段查询postgresql将不会在此表中搜索. 如果实施: >可以分别查询存档(从posts_archive中选择*),all(select * from posts_all)和production(select * from public.posts)数据 这是一般技术,您应该根据自己的需要进行调整. 进一步阅读:PostgreSQL inheritance,partitioning (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |