dbsize

| No Comments | No TrackBacks

PostgreSQL で dbsize をインストールして、DB のサイズを調べる。

% cd src/postgresql-7.3.4/contrib/dbsize
% make
sed 's,MODULE_PATHNAME,$libdir/dbsize,g' dbsize.sql.in >dbsize.sql
gcc -O2 -Wall -Wmissing-prototypes -Wmissing-declarations -fpic -I. -I../../src/include   -c -o dbsize.o dbsize.c
gcc -shared -o dbsize.so dbsize.o
rm dbsize.o
%

# make install
mkdir /usr/local/pgsql/share/contrib
mkdir /usr/local/pgsql/doc/contrib
/bin/sh ../../config/install-sh -c -m 644 dbsize.sql /usr/local/pgsql/share/contrib
/bin/sh ../../config/install-sh -c -m 755 dbsize.so /usr/local/pgsql/lib
/bin/sh ../../config/install-sh -c -m 644 ./README.dbsize /usr/local/pgsql/doc/contrib
#

% less dbsize.sql
CREATE FUNCTION database_size (name) RETURNS bigint
AS '$libdir/dbsize', 'database_size'
LANGUAGE C WITH (isstrict);

CREATE FUNCTION relation_size (text) RETURNS bigint
AS '$libdir/dbsize', 'relation_size'
LANGUAGE C WITH (isstrict);
% psql -U postgres testdb -f dbsize.sql
CREATE FUNCTION
CREATE FUNCTION
% psql testdb postgres
Welcome to psql 7.3.4, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

testdb=> SELECT database_size('testdb');
database_size
---------------
31813876
(1 row)

testdb=>

DB サイズは 31,813,876 bytes

% bc
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'.
31813876/8192
3883

8kbytes で割ると、共有バッファ 3883 必要ということになる。

No TrackBacks

TrackBack URL: http://www.grid5.net/mt/mt-trackback.cgi/506

Leave a comment

About this Entry

This page contains a single entry by dxy published on 2003年12月11日 03:37.

PANDUIT MPT5-8 was the previous entry in this blog.

IOS アップデート (準備編) is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Pages

Powered by Movable Type 5.01