Heim >Datenbank >MySQL-Tutorial >Postgres技巧

Postgres技巧

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 16:06:18974Durchsuche

在业务量大的时候 碰到需要添加索引,需要用到 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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn