性能优化最佳综合案例实践"/>
crt oracle查看执行计划,postgresql性能优化最佳综合案例实践
postgresql性能优化最佳综合案例实践-存储
美河学习在线
PostgreSQL 性能优化最佳综合案例实践
Digoal.Zhou
【前言】
本文建立了一个包含INSERT, UPDATE, SELECT 数据库请求的简单的业务模型, 并使用pgbench 模拟业务请求,
详细的阐述PostgreSQL 数据库的调优过程.
【正文】
【软件环境】
CentOS 5 x64
PostgreSQL 9.1.3
plproxy 2.3
pgbouncer 1.4.2
【测试模型】
设计一个包含INSERT, UPDATE, SELECT 语句的业务模型用于本优化案例.
业务逻辑 :
美河学习在线
【测试表】
create table user_info
(userid int,
engname text,
cnname text,
occupation text,
birthday date,
signname text,
email text,
qq numeric,
crt_time timestamp without time zone,
mod_time timestamp without time zone
);
create table user_session
(userid int,
logintime timestamp(0) without time zone,
login_count bigint default 0,
美河学习在线
logouttime timestamp(0) without time zone,
online_interval interval default interval '0'
);
create table user_login_rec
(userid int,
login_time timestamp without time zone,
ip inet
);
create table user_logout_rec
(userid int,
logout_time timestamp without time zone,
ip inet
);
【初始化数据】
insert into user_info (userid,engname,cnname,occupation,birthday,signname,email,qq,crt_time,mod_time)
select generate_series(1,
'digoal.zhou',
'德哥',
'DBA',
'1970-01-01'
,E'公益是一辈子的事, I\'m Digoal.Zhou, Just do it!',
'digoal@126',
276732431,
clock_timestamp (),
NULL ;
insert into user_session (userid) select generate_series (1;
set work_mem='2048MB';
set maintenance_work_mem='2048MB';
alter table user_info add constraint pk_user_info primary key (userid);
alter table user_session add constraint pk_user_session primary key (userid);
【业务函数】
-- 模拟用户登录的函数
create or replace function f_user_login
(i_userid int,
OUT o_userid int,
OUT o_engname text,
OUT o_cnname text,
OUT o_occupation text,
美河学习在线
OUT o_birthday date,
OUT o_signname tex
更多推荐
crt oracle查看执行计划,postgresql性能优化最佳综合案例实践
发布评论