postgres crash recovery
目前,如果数据库crash,PostgreSQL恢复时,对2PC处理机制如下
How MVCC work
fzou=# CREATE TABLE vis (fzou(# id serial,fzou(# is_active booleanfzou(# );CREATE TABLEfzou=# fzou=# INSERT INTO vis (is_active) VALUES (FALSE);INSERT 0 1fzou=# fzou=# SELECT ctid, xmin, xmax, * FROM vis; ctid | xmin | xm...
SQL优化(一) Merge Join vs. Hash Join vs. Nested Loop
本文转发自Jason’s Blog,原文链接 http://www.jasongj.com/2015/03/07/Join1/Nested Loop,Hash Join,Merge Join介绍 Nested Loop:对于被连接的数据子集较小的情况,Nested Loop是个较好的选择。Nested Loop就是扫描一个表(外表),每读到一条记录,就根据Join字段上的索引去另一张表(内表)里面查找,...
The Visibility Map (and other relation forks)
The Visibility Map is a simple data structure associated with every heap relation (table). It is a "relation fork"; an on-disk ancillary file associated with a particular relation (table or index). Note that index relations (that is, indexes) do not have a visibility map associated with them. The ...
SQL优化 —— 读懂执行计划
Bucket and Batch I saw that functions which use hash join, like as ExecHashGetBucketAndBatch and ExecScanHashBucket, have bucket and batch concepts.So, I would like to know the differences between bucket and batch. I dont understand tables partitioning mechanism in hash join.A bucket is, well, on...
Postgres Query tuning
IPK --> unique, not nullUnique contrast --> unique, nullableAuto vacuum select name,setting from pg_settings;autovacuum_analyze_scale_factor: Modification (insert/update/delete rows) reach autovacuum_analyze_threshold\d+ [table_name]\d+ [table_name]\h alterALTER TABLE [tabl...
PostgreSQL 事务模型介绍
PostgreSQL有自己的事务实现模型。总体上分为三层:top layer, middle layer和bottom layer。1. Top LayerTop Layer主要由用户控制,对用户可见。这一层的事务,主要由用户来决定事务的发起与结束。事务生命周期由用户控制,是high-level的。也就是通常所说的事务块,transaction block。当用户发起:BEGIN, ...
postgresql 的三类日志
一、PostgreSQL有3种日志: 1)pg_log(数据库运行日志) 内容可读 默认关闭的,需要设置参数启动 2)pg_xlog(WAL 日志,即重做日志) 内容一般不具有可读性 强制开启 3)pg_clog(事务提交日志,记录的是...
Postgres Checkpoint
PostgreSQL checkpoint原理 1.PG检查点的类型Shutdown检查点:在PG实例shutdown时做的检查点Recovery End检查点:在recovery 结束阶段做的检查点,类似于shutdown检查点,只不过在WAL恢复结束时发起。Immediate检查点:不仅仅创建检查点,而且会马上做。这类请求一般在比较紧急的情况下,需要马上获取...
PostgreSQL索引
PostgreSQL提供了好几种索引类型:B-tree, Hash, GiST, SP-GiST和GIN 。B-tree索引也可以用来按照排序顺序检索数据。这并不总是比一个简单的扫描和排序快, 但通常是有帮助的。Hash 索引只能处理简单的等于比较。当一个索引了的列涉及到使用= 操作符进行比较的时候,查询规划器会考虑使用 Hash 索引。GiST 索引不是...
Postgresql 备份恢复
在线备份以及即时恢复(PITR)组合文件系统备份与WAL文件的备份。如果需要恢复,我们就恢复备份, 然后重放备份了的WAL文件,把备份恢复到当前的时间。注意: pg_dump和 pg_dumpall没有产生文件系统级别备份,并且不能作为 连续归档解决方案的一部分。比如备份是符合逻辑的并且不包含 WAL重放使用的足够信息。...
PostgreSQL进程/服务器配置
postgres 20079 1 0 Jul07 ? 00:00:41 /usr/pgsql-9.2/bin/postmaster -p 60904 -D /u01/app/postgres/data/monicrmpostgres 20081 20079 0 Jul07 ? 00:00:00 postgres: logger process &nb...