首页  >  文章  >  数据库  >  Postgres技巧

Postgres技巧

WBOY
WBOY原创
2016-06-07 16:06:18869浏览

在业务量大的时候 碰到需要添加索引,需要用到 CONCURRENTLY,不然你的库很容易会坏的 如 create index CONCURRENTLY idx_order_records_bank_statist_uid on order_records(statist_uid) 见 http://www.postgresql.org/docs/9.1/static/sql-createindex.htm

在业务量大的时候 碰到需要添加索引,需要用到 CONCURRENTLY,不然你的库很容易会坏的

create index CONCURRENTLY idx_order_records_bank_statist_uid on order_records(statist_uid)

http://www.postgresql.org/docs/9.1/static/sql-createindex.html

在大的业务量下,如果你要去执行一些费时耗数据库的任务 有时会发现 某一个任务 还在暗地里执行着 需要我们 手动的 关闭 该任务

如果你是 kill 对应的pid ,那么你玩了,你很有可能会出现 数据库的问题

保险的做法是 用 PG_CANCEL_BACKEND

通过 如下查找对应的PID

select pid, trim(starttime) as start, 
duration, trim(user_name) as user,
substring (query,1,40) as querytxt
from stv_recents
where status = 'Running';

查看

select pg_cancel_backend(802);

通过如下 杀掉 任务

pg_cancel_backend( pid )

http://docs.aws.amazon.com/redshift/latest/dg/PG_CANCEL_BACKEND.html

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn