小编sha*_*dov的帖子

延迟或等待声明

我有一个500,000行sql脚本:

update users set region_id = 9814746 where id = 101 and region_id is null;
update users set region_id = 9814731 where id = 102 and region_id is null;
update users set region_id = 3470676 where id = 103 and region_id is null;
Run Code Online (Sandbox Code Playgroud)

我想每50行插入10秒的延迟.pgsql是否有像t-sql这样的waitfor语句.

谢谢.

postgresql sleep wait

20
推荐指数
3
解决办法
2万
查看次数

Postgres分区 - 性能问题

我有一个按周分区的表.start_time上有一个索引当我运行它时 -

EXPLAIN SELECT COUNT(uniq_id) FROM call_fact WHERE CAST(start_time AS DATE) = '2018-01-23' AND source_key=2;
Run Code Online (Sandbox Code Playgroud)

它会扫描每个分区表,而不是转到正确的子表.查询优化器是否应该足够聪明才能选择正确的子表?有没有办法强制postgres去正确的子表?

EXPLAIN(analyze, buffers) SELECT COUNT(uniq_id) FROM call_fact WHERE CAST(start_time AS DATE) = '2018-01-23' AND source_key=2;
                                                                                                 QUERY PLAN                                                                                                 
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Aggregate  (cost=649579.52..649579.53 rows=1 width=26) (actual time=845.998..845.998 rows=1 loops=1)
   Buffers: shared hit=34839 read=1312
   ->  Append  (cost=0.12..647969.68 rows=643937 width=26) (actual time=175.416..792.387 rows=457658 loops=1)
         Buffers: shared hit=34839 read=1312
         ->  Index Scan using call_fact_cast_start_time_idx on call_fact  (cost=0.12..8.14 rows=1 width=26) (actual time=0.006..0.006 rows=0 loops=1)
               Index Cond: ((start_time)::date = '2018-01-23'::date)
               Filter: (source_key = …
Run Code Online (Sandbox Code Playgroud)

sql postgresql

6
推荐指数
1
解决办法
166
查看次数

插入到表..链接服务器上的exec不起作用

这有效,返回结果集:

exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
Run Code Online (Sandbox Code Playgroud)

当我尝试将结果集插入表中时:

insert into rowcount_sub (tablename,rowcnt)
exec ('select ''col'', count(1) from test.dbo.[Table1] with (nolock)') at svrA
Run Code Online (Sandbox Code Playgroud)

失败给出这个错误:

OLE DB provider "SQLNCLI10" for linked server "svrA" returned message "No transaction is active.".
Msg 7391, Level 16, State 2, Line 1
The operation could not be performed because OLE DB provider "SQLNCLI10" for linked server "svrA" was unable to begin a distributed transaction.
Run Code Online (Sandbox Code Playgroud)

sql sql-server-2008

4
推荐指数
2
解决办法
9747
查看次数

期待刮一个网站

我正在寻找像yelp.com这样的网站,以获得他们在那里所有酒吧的列表.是否有任何工具或脚本可以帮助我做到这一点.

screen-scraping web

3
推荐指数
1
解决办法
4133
查看次数

使用Cacti监视Microsoft SQL服务器

是否有人使用Cacti来监视SQL服务器计数器(磁盘队列长度,I/O请求等).如果你是,你是怎么做到这一点的?基本上我在SQL Server上收集了许多性能计数器.我需要一种方法来创建图形并切片和切块我收集的数据?如果您知道其他图形解决方案,请告诉我们?

sql sql-server

2
推荐指数
1
解决办法
5094
查看次数

开始...每50行提交一次

我有一个500,000行的sql脚本.

update users set region_id = 9814746 where id = 101 and region_id is null;
update users set region_id = 9814731 where id = 102 and region_id is null;
update users set region_id = 3470676 where id = 103 and region_id is null;
...
....
Run Code Online (Sandbox Code Playgroud)

我需要能够生成一个脚本,每50行开始...提交.我该怎么做呢?我将在pg-admin中运行它.

谢谢,沙拉多夫

postgresql

0
推荐指数
1
解决办法
1000
查看次数