>  기사  >  데이터 베이스  >  Postgres技巧

Postgres技巧

WBOY
WBOY원래의
2016-06-07 16:06:18868검색

在业务量大的时候 碰到需要添加索引,需要用到 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으로 문의하세요.