文档章节

pgfincore

LIAN-SA
 LIAN-SA
发布于 2014/09/15 15:30
字数 548
阅读 146
收藏 0

【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>

一、系统

# cat /etc/issue

CentOS release 6.5 (Final)

Kernel \r on an \m

 

# uname -a

Linux barman 2.6.32-431.11.2.el6.x86_64 #1 SMP Tue Mar 25 19:59:55 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

 

# cat /etc/hosts

 

二、安装

2.1 简介

With PostgreSQL, each Table or Index is splitted in segments of (usually) 1GB, and each segment is splitted in pages in memory then in blocks for the filesystem.

 

Those functions let you know which and how many disk block from a relation are in the page cache of the operating system. It can provide the result as a VarBit and can be stored in a table. Then using this table, it is possible to restore the page cache state for each block of the relation, even in another server, thanks to Streaming Replication.

 

Other functions are used to set a POSIX_FADVISE flag on the entire relation (each segment). The more usefull are probably WILLNEED and DONTNEED which push and pop blocks of each segments of a relation from page cache, respectively.

 

Each functions are call with at least a table name or an index name (or oid) as a parameter and walk each segment of the relation.

 

注意:pgfincore将对象缓存在操作系统内存中,并不占用数据库cache

要求:Pg version >=8.3

2.2 安装

# su - postgres

$ wget http://pgfoundry.org/frs/download.php/3186/pgfincore-v1.1.1.tar.gz

$ tar -zxvf pgfincore-v1.1.1.tar.gz

$ cd pgfincore-1.1.1/

$ make

$ make install

2.3 引入扩展

Pg Version >= 9.1

pgbench=# create extension pgfincore;

CREATE EXTENSION

 

Other

psql pgbench -f pgfincore.sql

 

至此,安装完毕。

 

 

查看引入的函数:

pgbench=# select proname,prosrc from pg_proc where proname like 'pgfadvise%' or proname like 'pgfincore%' or proname like 'pgsysconf%';

       proname        |                                 prosrc                                

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

 pgsysconf            | pgsysconf

 pgsysconf_pretty     |                                                                       +

                      | select pg_size_pretty(os_page_size)                  as os_page_size, +

                      |        pg_size_pretty(os_pages_free * os_page_size)  as os_pages_free,+

                      |        pg_size_pretty(os_total_pages * os_page_size) as os_total_pages+

                      | from pgsysconf()

 pgfadvise            | pgfadvise

 pgfadvise_willneed   | SELECT pgfadvise($1, 'main', 10)

 pgfadvise_dontneed   | SELECT pgfadvise($1, 'main', 20)

 pgfadvise_normal     | SELECT pgfadvise($1, 'main', 30)

 pgfadvise_sequential | SELECT pgfadvise($1, 'main', 40)

 pgfadvise_random     | SELECT pgfadvise($1, 'main', 50)

 pgfadvise_loader     | pgfadvise_loader

 pgfadvise_loader     | SELECT pgfadvise_loader($1, 'main', $2, $3, $4, $5)

 pgfincore            | pgfincore

 pgfincore            | SELECT * from pgfincore($1, 'main', $2)

 pgfincore            | SELECT * from pgfincore($1, 'main', false)

(13 rows)

 

三、示例

3.1 查看当前OSblockpage情况

pgbench=# select * from pgsysconf();

 os_page_size | os_pages_free | os_total_pages

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

         4096 |         30991 |         255086

(1 row)

 

pgbench=# select * from pgsysconf_pretty();

 os_page_size | os_pages_free | os_total_pages

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

 4096 bytes   | 121 MB        | 996 MB

(1 row)

 

os_page_size:操作系统内存块大小

os_pages_free:操作系统空闲的内存大小

os_total_pages:操作系统总共的内存大小

 

3.2 缓存对象

pgbench=# select * from pgfadvise_willneed('pgbench_accounts');

     relpath      | os_page_size | rel_os_pages | os_pages_free

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

 base/16384/16460 |         4096 |        33250 |         32033

(1 row)

 

rel_os_pages:该对象在操作系统内存中占用的内存页

3.3 卸载对象

pgbench=# select * from pgfadvise_dontneed('pgbench_accounts');

     relpath      | os_page_size | rel_os_pages | os_pages_free

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

 base/16384/16460 |         4096 |        33250 |         65234

(1 row)

 

四、参考

http://pgfoundry.org/projects/pgfincore/

https://github.com/klando/pgfincore

© 著作权归作者所有

LIAN-SA
粉丝 29
博文 36
码字总数 76225
作品 0
广州
数据库管理员
私信 提问
利用系统缓存提高PostgreSQL操作效率

环境介绍: OS:Centos 6.4 64bit Database:PostgreSQL9.4 Memory:2G CPU:1核 下载安装: 在pgfoundry下载pgfincore-v1.1.1.tar.gz,,将源码解压到数据库源码下的contrib下。不要在其git...

PGSmith
2015/12/17
5.7K
0
pg_prewarm 与 pgfincore的区别

pg_prewarm 集成于 contrib pgfincore:https://github.com/klando/pgfincore 1、pgfincore 主要是利用 POSIX 的 posixfadvise函数,pgfadviseloaderfile中可以看到它的调用,支持两种模式:...

有理想的猪
2016/05/19
335
0
PostgreSQL 内存页管理函数 - PgFincore

PgFincore 包含一组用于管理 PostgreSQL 内存中页面的函数。 使用PostgreSQL,每个表或索引通常都分成1GB的段,并且每个段都分为内存中的页面和文件系统的块。 这些功能使您可以知道某个关系...

匿名
12/03
1K
1

没有更多内容

加载失败,请刷新页面

加载更多

没有更多内容

写的简单sh脚本2

#!/bin/bashexport LANG="en_US.UTF-8"#chmod +x filename 记得给文件加可执行权限#./vsimstart.sh#启动vsim项目echo "start vism"#207------------------------------assets=vsim-a......

hexiaoming123
昨天
4
0
java基础(1)变量和常量

概要和总结: 数据类型图: 基本数据类型:只有基本功能-----保存数据 (4类8种)byte-short-int-long-float-double-char-boolean 引用数据类型:有更多功能,保存数据,处理数据...

煌sir
昨天
5
0
年底了,整理了一份程序员面试必看的文章合集

本系列文章整合了本号发表和转载过的,有关技术招聘干货、笔试面试经验和技巧、简历、招聘等方面的精品文章,希望对想要找工作,以及正在找工作的你,能够有所帮助。 原创面试干货文章 校招季...

Java技术江湖
昨天
4
0
curl 命令行下工作的文件传输工具---应用篇

抓取页面内容到一个文件中 curl -o home.html http://www.sina.com.cn 模拟用户登录 # 此参数相当于设置http头 Authorization:curl --user user:password http://blog.mydomain.com/logi...

edison_kwok
昨天
4
0
JAVA--高级基础开发Cookie实现记住用户名和密码

前端JSP页面: 实现保存用户名和密码<%@ page import="java.net.URLDecoder" %><%@ page contentType="text/html;charset=UTF-8" language="java" %><html> <head> <title>Coo......

李文杰-yaya
昨天
15
0

没有更多内容

加载失败,请刷新页面

加载更多

返回顶部
顶部