Redian新闻
>
东北大学环境工程系读本科怎么样?
avatar
东北大学环境工程系读本科怎么样?# Environmental - 环境科学与工程
y*n
1
请问各位有EB1A经验的前辈,小弟正在DIY申请,考的就是自己的research。其中有两
篇自己的文章被自己所在学校的媒体专门发文报道了,然后这些报道又原封不动的被其
他一些比较知名的网站媒体转载了。
我估计学校的媒体报道可能不算是media coverage。那么问题来了,后边这些网站媒体
的转载可不可以claim成media coverage呢?如果不能的话,难道这些就一点用都没有
了么?
求帮助啊~
avatar
a*j
2
请教各位一个很急的问题。
我随老公来美,他是L1,我是L2签证,已来两年。目前我的签证快要到期了,但是老公
的签证还有一年才到期。老公的公司说可以帮我在美国这边申请延期签证,当然我也可
以选择自己回国去重新签证。我想让公司帮我在这边延期,但是听说B类签证在这边延
期可能会影响下次来美签证,我想请问L类签证延期是否也会有这个影响,如果真是这
样,那我宁愿麻烦一次,回国去签。多谢各位了!请大家给我些建议吧。再次感谢!
avatar
b*d
3
大家都用哪一个? 我用的这个:
http://www.acm.org/pubs/submissions/latex_style/
但是当我要submit for review的时候,我发现要求是double space。
这个Latex template出来的pdf似乎远小于double space,比single space多不了多少。
是直接用这个template就可以了啦,还是真得改double space?
谢谢!
avatar
b*a
4
Now we can only delete them in 1 hour. How to make it in 30 mins?
Thanks,
Ming
avatar
d*9
5
帮一个老乡小孩问的。我不是学环境的,所以不大了解。谢了。
avatar
B*g
6
what database?
which version?
table partitioned?
any audit/archive is using?

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming

avatar
b*a
7
发信人: Beijing (中国万岁,北京加油), 信区: Database
标 题: Re: How to delete 40 millions records in a 400 millions indexe
发信站: BBS 未名空间站 (Tue Jan 24 17:58:08 2012, 美东)
what database? sql server 2008
which version?
table partitioned? no
any audit/archive is using? no idea...
【 在 buaa (ming) 的大作中提到: 】
avatar
b*a
8
I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster...

【在 b**a 的大作中提到】
: 发信人: Beijing (中国万岁,北京加油), 信区: Database
: 标 题: Re: How to delete 40 millions records in a 400 millions indexe
: 发信站: BBS 未名空间站 (Tue Jan 24 17:58:08 2012, 美东)
: what database? sql server 2008
: which version?
: table partitioned? no
: any audit/archive is using? no idea...
: 【 在 buaa (ming) 的大作中提到: 】

avatar
i*a
9
Do a larger batch than 10k should help. And just do delete without the sub
select.m
Are your lookup parameters indexed?
And what's the purpose of (MAXDOP 1)?

)
[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
c*d
10
这个是dba interview最常见的问题吧

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming

avatar
b*a
11
The where clause is using the field that is indexed

【在 i****a 的大作中提到】
: Do a larger batch than 10k should help. And just do delete without the sub
: select.m
: Are your lookup parameters indexed?
: And what's the purpose of (MAXDOP 1)?
:
: )
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
12
Can you do delete without the sub
select. Put the where clause in to the delete statement.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: The where clause is using the field that is indexed
avatar
b*a
13
I actually get the idea from the following link:
http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
A view is supposed to be faster but i did not figure out the way to create a
view in begin and end block so I gave up.

【在 i****a 的大作中提到】
: Can you do delete without the sub
: select. Put the where clause in to the delete statement.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
14
Try with just delete top 100000 from tbl where ....

a
[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: I actually get the idea from the following link:
: http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
: A view is supposed to be faster but i did not figure out the way to create a
: view in begin and end block so I gave up.

avatar
B*g
15
同时run 10个会不会快?

create

【在 i****a 的大作中提到】
: Try with just delete top 100000 from tbl where ....
:
: a
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
b*a
16
How?
Thanks.

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
c*d
17
同时run 10个,每个delete 4 millions record?
这个方法性能更慢

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
c*d
18
没看太明白
是不是要删除transacitons表中某段时间的记录
如果要删除的记录超过10000条,10001条以后的就不删除了?

)

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
b*a
19
No. This is to delete 10000 each batch and keep deleting untill every
records that qualified get deleted.

【在 c*****d 的大作中提到】
: 没看太明白
: 是不是要删除transacitons表中某段时间的记录
: 如果要删除的记录超过10000条,10001条以后的就不删除了?
:
: )

avatar
i*a
20
Then you have a bug in the while condition.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: No. This is to delete 10000 each batch and keep deleting untill every
: records that qualified get deleted.

avatar
b*a
21
what is it?
Thanks.

【在 i****a 的大作中提到】
: Then you have a bug in the while condition.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
22
Never mind, its fine.
Just try different coding and batch sizes.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: what is it?
: Thanks.

avatar
B*g
23
假设每个删除都删除不同的range呢?

【在 c*****d 的大作中提到】
: 同时run 10个,每个delete 4 millions record?
: 这个方法性能更慢

avatar
y*w
24
10000的批次太小,换成10w或100w重新跑。问下你们的dba,保证log空间足够。

WITH(NOLOCK
)
@EndDate)

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
y*w
25
sql server的锁和oracle的很不一样。

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
B*g
26
2008不是改善了吗?另外如果有partition可行吗?

【在 y****w 的大作中提到】
: sql server的锁和oracle的很不一样。
avatar
y*w
27
并发delete总是要受影响的吧。各个并发之间必须有严格的界限,不然以set的无序特
性,跑跑就锁死了,或操作旧数据了。
lz这个没table partition,用partition/order by硬排序出来或许行,用rank避免最
后那组值的随机性.
没注意sql 2008支持不支持类似currently committed语义。

【在 B*****g 的大作中提到】
: 2008不是改善了吗?另外如果有partition可行吗?
avatar
j*n
28
partitioning will definitely improve the performance.
specially if the partition(s) hold only the records that will be deleted,
then the delete action will take no time via dropping the partition(s).

【在 B*****g 的大作中提到】
: 2008不是改善了吗?另外如果有partition可行吗?
avatar
y*w
29
sql大拿说说sql server 2008/denali的锁机制,在并发读写方面的改进?

【在 j*****n 的大作中提到】
: partitioning will definitely improve the performance.
: specially if the partition(s) hold only the records that will be deleted,
: then the delete action will take no time via dropping the partition(s).

avatar
c*d
30
除非你知道每个range在哪个block上

【在 B*****g 的大作中提到】
: 假设每个删除都删除不同的range呢?
avatar
i*a
31
I think mainly the time is spend on i/o. But can't tell without a perfmon
trace.

[发表自未名空间手机版 - m.mitbbs.com]

【在 B*****g 的大作中提到】
: 假设每个删除都删除不同的range呢?
avatar
B*g
32
他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
以独立

【在 y****w 的大作中提到】
: 并发delete总是要受影响的吧。各个并发之间必须有严格的界限,不然以set的无序特
: 性,跑跑就锁死了,或操作旧数据了。
: lz这个没table partition,用partition/order by硬排序出来或许行,用rank避免最
: 后那组值的随机性.
: 没注意sql 2008支持不支持类似currently committed语义。

avatar
B*g
33
server上很多CPU的

【在 i****a 的大作中提到】
: I think mainly the time is spend on i/o. But can't tell without a perfmon
: trace.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
B*g
34
zkss

【在 c*****d 的大作中提到】
: 除非你知道每个range在哪个block上
avatar
i*a
35
Not cpu. I'm refering to disk i/o.
Without optimizing query, most likely the bottle neck is at i/o. Running
mulitple instances of the query wouldn't help if they all wait for the disk.

[发表自未名空间手机版 - m.mitbbs.com]

【在 B*****g 的大作中提到】
: server上很多CPU的
avatar
B*g
36
这个table显然是需要partition,哈哈

【在 j*****n 的大作中提到】
: partitioning will definitely improve the performance.
: specially if the partition(s) hold only the records that will be deleted,
: then the delete action will take no time via dropping the partition(s).

avatar
B*g
37
多几个SQL就把Disk搞死了,呵呵

disk.

【在 i****a 的大作中提到】
: Not cpu. I'm refering to disk i/o.
: Without optimizing query, most likely the bottle neck is at i/o. Running
: mulitple instances of the query wouldn't help if they all wait for the disk.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
y*w
38
lz这个瓶颈我认为是因为batch size太小带来的循环冗余开销。原先那个sql跑起来估计机器的
cpu/io都不能真正忙起来,但换个角度过来说,总体cpu/io比一次删除的要多了n多倍。
他那个表有400M rows,是个大型库,机器应该差不到哪里去,日志配置应该也不会太
小气。删10M记录应该比做1000次每次10000条要快的多,lz的要求也就是提高一半,改
下batch size应该够用了。lz应该试试然后贴个结果上来。

Running
the
disk.

【在 i****a 的大作中提到】
: Not cpu. I'm refering to disk i/o.
: Without optimizing query, most likely the bottle neck is at i/o. Running
: mulitple instances of the query wouldn't help if they all wait for the disk.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
B*g
39
这个需要测试,据俺测试oracle9i,一般来说1w和10w差不多。另外lz的code为啥要
hardcode 10000很多次?

估计机器的
倍。

【在 y****w 的大作中提到】
: lz这个瓶颈我认为是因为batch size太小带来的循环冗余开销。原先那个sql跑起来估计机器的
: cpu/io都不能真正忙起来,但换个角度过来说,总体cpu/io比一次删除的要多了n多倍。
: 他那个表有400M rows,是个大型库,机器应该差不到哪里去,日志配置应该也不会太
: 小气。删10M记录应该比做1000次每次10000条要快的多,lz的要求也就是提高一半,改
: 下batch size应该够用了。lz应该试试然后贴个结果上来。
:
: Running
: the
: disk.

avatar
y*w
40
随手的脚本写法,保证能删光,又不想费事儿去搞到精确的批次,要不加个@@rowcount
=0跳出来也就行了。

【在 B*****g 的大作中提到】
: 这个需要测试,据俺测试oracle9i,一般来说1w和10w差不多。另外lz的code为啥要
: hardcode 10000很多次?
:
: 估计机器的
: 倍。

avatar
y*w
41
这么多的行删除,需要的行锁太多; 如果锁升级的话影响怎样,页锁/表锁会破坏本来sql语句之间的
隔离?。 sql server没那么熟,不好说。

【在 B*****g 的大作中提到】
: 他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
: 以独立

avatar
B*g
42
等待大牛中

sql语句之间的

【在 y****w 的大作中提到】
: 这么多的行删除,需要的行锁太多; 如果锁升级的话影响怎样,页锁/表锁会破坏本来sql语句之间的
: 隔离?。 sql server没那么熟,不好说。

avatar
a9
43
先把不重要的索引删掉。

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming

avatar
c*d
44
假如你run 10个batch,这些batch都在修改同一个db block or db page

【在 B*****g 的大作中提到】
: zkss
avatar
c*d
45
时间字段上的range ---逻辑
data blocks range ---物理
一般情况下是不会一一对应的
很可能一个block上有今天的数据,也有100年以前的数据

【在 B*****g 的大作中提到】
: 他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
: 以独立

avatar
y*w
46
数据量小时行锁就行了。lz这个行锁肯定不够用,要上页锁甚至表锁。看dbms具体实现lock wait
的时间可能差很多。 逻辑上独立这个前提就有可能导致实现上的优化。所以我说还是得真懂sql
server的来说说sql server目前以及可预期版本的实现。
再说今天很对的东西,过几年也许就变成错的了。

【在 c*****d 的大作中提到】
: 时间字段上的range ---逻辑
: data blocks range ---物理
: 一般情况下是不会一一对应的
: 很可能一个block上有今天的数据,也有100年以前的数据

avatar
B*g
47
同一时间在一起的可能性很大。LZ每次就锁1w个,delete01也许会lock delete02、03
,但总不会把02-10(假设开10个)都lock住吧。当然,对SQL server的lock不是很精
通,期待大牛详解SQL server Lock。另外如果SQL搞不定,可以考虑hibernate。

【在 c*****d 的大作中提到】
: 时间字段上的range ---逻辑
: data blocks range ---物理
: 一般情况下是不会一一对应的
: 很可能一个block上有今天的数据,也有100年以前的数据

avatar
c*d
48
“同一时间在一起的可能性很大”,未必,看应用
OLTP一个block上什么时间的数据都会有

03

【在 B*****g 的大作中提到】
: 同一时间在一起的可能性很大。LZ每次就锁1w个,delete01也许会lock delete02、03
: ,但总不会把02-10(假设开10个)都lock住吧。当然,对SQL server的lock不是很精
: 通,期待大牛详解SQL server Lock。另外如果SQL搞不定,可以考虑hibernate。

avatar
c*d
49
我没搞清楚lz是必须用sql delete的方法来删除
还是可以用其他方法来实现?
avatar
B*g
50
据说hibernate比SQL快

【在 c*****d 的大作中提到】
: 我没搞清楚lz是必须用sql delete的方法来删除
: 还是可以用其他方法来实现?

avatar
y*w
51
这sql得写多烂?

【在 B*****g 的大作中提到】
: 据说hibernate比SQL快
avatar
b*a
52
yes we have to do it in sql.

【在 c*****d 的大作中提到】
: 我没搞清楚lz是必须用sql delete的方法来删除
: 还是可以用其他方法来实现?

avatar
y*w
53
have you tried bigger batch size? start with 1M.

【在 b**a 的大作中提到】
: yes we have to do it in sql.
avatar
b*a
54
Log drive does not have that big space...
Thanks.
Ming

【在 y****w 的大作中提到】
: have you tried bigger batch size? start with 1M.
avatar
j*7
55
那个Delete语句可以这么写:
DELETE TOP(10000) FROM Transactions
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
Not sure if it's faster. The "select *" is bad in my eyes.
avatar
b*a
56
http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
According to that link, that is faster actually than delete directly...

【在 j*******7 的大作中提到】
: 那个Delete语句可以这么写:
: DELETE TOP(10000) FROM Transactions
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
: Not sure if it's faster. The "select *" is bad in my eyes.

avatar
y*w
58
应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
差别才对,假如sql optimizer没干傻事的话。

【在 j*******7 的大作中提到】
: 那个Delete语句可以这么写:
: DELETE TOP(10000) FROM Transactions
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
: Not sure if it's faster. The "select *" is bad in my eyes.

avatar
B*g
59
顶,tuning就是调试

【在 y****w 的大作中提到】
: 应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
: 差别才对,假如sql optimizer没干傻事的话。

avatar
t*3
60
用TRUNCATE
avatar
b*a
61
This is a variation from this article. Sounds very reasonable so I did not
do test.
Plus i do not have enough space and data in our dev platform to test so...
I am not a sql guy...

【在 y****w 的大作中提到】
: 应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
: 差别才对,假如sql optimizer没干傻事的话。

avatar
B*g
62
加入CINAOUG,你也可以成为sql guy

【在 b**a 的大作中提到】
: This is a variation from this article. Sounds very reasonable so I did not
: do test.
: Plus i do not have enough space and data in our dev platform to test so...
: I am not a sql guy...

avatar
g*l
63
建一个一模一样的TABLE名字是TABLE_TEMP,注意PK, INDEXES, BULK INSERT你想留住
的RECORD INTO TABLE_TEMP,DROP OLD TABLE, RENAME TABLE_TEMP TO TABLE,
RECOMPILE TABLE
avatar
b*a
64
Now we can only delete them in 1 hour. How to make it in 30 mins?
Thanks,
Ming
Update:
Tried all i can except partitioned table. We cannot drop the index and rebuild it because other hourly sql job is going to insert a lot of records in the same table. Seemed no way to ensure it will finish in 30 mins so my solution is to add a waitfor delay 0.2 in every loop. In this way, the delete will finish much longer (2:30) but it will not affect any other jobs.
avatar
B*g
65
what database?
which version?
table partitioned?
any audit/archive is using?

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming
: Update:
: Tried all i can except partitioned table. We cannot drop the index and rebuild it because other hourly sql job is going to insert a lot of records in the same table. Seemed no way to ensure it will finish in 30 mins so my solution is to add a waitfor delay 0.2 in every loop. In this way, the delete will finish much longer (2:30) but it will not affect any other jobs.

avatar
b*a
66
发信人: Beijing (中国万岁,北京加油), 信区: Database
标 题: Re: How to delete 40 millions records in a 400 millions indexe
发信站: BBS 未名空间站 (Tue Jan 24 17:58:08 2012, 美东)
what database? sql server 2008
which version?
table partitioned? no
any audit/archive is using? no idea...
【 在 buaa (ming) 的大作中提到: 】
avatar
b*a
67
I am using sth like this now:
DECLARE @count2 int
SET @count2 = 10000
WHILE @count2 >= 10000
BEGIN
DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
temp OPTION (MAXDOP 1)
SELECT @count2 = @@ROWCOUNT
END
and i really need it to run faster...

【在 b**a 的大作中提到】
: 发信人: Beijing (中国万岁,北京加油), 信区: Database
: 标 题: Re: How to delete 40 millions records in a 400 millions indexe
: 发信站: BBS 未名空间站 (Tue Jan 24 17:58:08 2012, 美东)
: what database? sql server 2008
: which version?
: table partitioned? no
: any audit/archive is using? no idea...
: 【 在 buaa (ming) 的大作中提到: 】

avatar
i*a
68
Do a larger batch than 10k should help. And just do delete without the sub
select.m
Are your lookup parameters indexed?
And what's the purpose of (MAXDOP 1)?

)
[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
c*d
69
这个是dba interview最常见的问题吧

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming
: Update:
: Tried all i can except partitioned table. We cannot drop the index and rebuild it because other hourly sql job is going to insert a lot of records in the same table. Seemed no way to ensure it will finish in 30 mins so my solution is to add a waitfor delay 0.2 in every loop. In this way, the delete will finish much longer (2:30) but it will not affect any other jobs.

avatar
b*a
70
The where clause is using the field that is indexed

【在 i****a 的大作中提到】
: Do a larger batch than 10k should help. And just do delete without the sub
: select.m
: Are your lookup parameters indexed?
: And what's the purpose of (MAXDOP 1)?
:
: )
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
71
Can you do delete without the sub
select. Put the where clause in to the delete statement.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: The where clause is using the field that is indexed
avatar
b*a
72
I actually get the idea from the following link:
http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
A view is supposed to be faster but i did not figure out the way to create a
view in begin and end block so I gave up.

【在 i****a 的大作中提到】
: Can you do delete without the sub
: select. Put the where clause in to the delete statement.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
73
Try with just delete top 100000 from tbl where ....

a
[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: I actually get the idea from the following link:
: http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
: A view is supposed to be faster but i did not figure out the way to create a
: view in begin and end block so I gave up.

avatar
B*g
74
同时run 10个会不会快?

create

【在 i****a 的大作中提到】
: Try with just delete top 100000 from tbl where ....
:
: a
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
b*a
75
How?
Thanks.

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
c*d
76
同时run 10个,每个delete 4 millions record?
这个方法性能更慢

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
c*d
77
没看太明白
是不是要删除transacitons表中某段时间的记录
如果要删除的记录超过10000条,10001条以后的就不删除了?

)

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
b*a
78
No. This is to delete 10000 each batch and keep deleting untill every
records that qualified get deleted.

【在 c*****d 的大作中提到】
: 没看太明白
: 是不是要删除transacitons表中某段时间的记录
: 如果要删除的记录超过10000条,10001条以后的就不删除了?
:
: )

avatar
i*a
79
Then you have a bug in the while condition.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: No. This is to delete 10000 each batch and keep deleting untill every
: records that qualified get deleted.

avatar
b*a
80
what is it?
Thanks.

【在 i****a 的大作中提到】
: Then you have a bug in the while condition.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
i*a
81
Never mind, its fine.
Just try different coding and batch sizes.

[发表自未名空间手机版 - m.mitbbs.com]

【在 b**a 的大作中提到】
: what is it?
: Thanks.

avatar
B*g
82
假设每个删除都删除不同的range呢?

【在 c*****d 的大作中提到】
: 同时run 10个,每个delete 4 millions record?
: 这个方法性能更慢

avatar
y*w
83
10000的批次太小,换成10w或100w重新跑。问下你们的dba,保证log空间足够。

WITH(NOLOCK
)
@EndDate)

【在 b**a 的大作中提到】
: I am using sth like this now:
: DECLARE @count2 int
: SET @count2 = 10000
: WHILE @count2 >= 10000
: BEGIN
: DELETE temp from ( SELECT TOP 10000 * FROM Transactions WITH(NOLOCK)
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate)
: temp OPTION (MAXDOP 1)
: SELECT @count2 = @@ROWCOUNT
: END

avatar
y*w
84
sql server的锁和oracle的很不一样。

【在 B*****g 的大作中提到】
: 同时run 10个会不会快?
:
: create

avatar
B*g
85
2008不是改善了吗?另外如果有partition可行吗?

【在 y****w 的大作中提到】
: sql server的锁和oracle的很不一样。
avatar
y*w
86
并发delete总是要受影响的吧。各个并发之间必须有严格的界限,不然以set的无序特
性,跑跑就锁死了,或操作旧数据了。
lz这个没table partition,用partition/order by硬排序出来或许行,用rank避免最
后那组值的随机性.
没注意sql 2008支持不支持类似currently committed语义。

【在 B*****g 的大作中提到】
: 2008不是改善了吗?另外如果有partition可行吗?
avatar
j*n
87
partitioning will definitely improve the performance.
specially if the partition(s) hold only the records that will be deleted,
then the delete action will take no time via dropping the partition(s).

【在 B*****g 的大作中提到】
: 2008不是改善了吗?另外如果有partition可行吗?
avatar
y*w
88
sql大拿说说sql server 2008/denali的锁机制,在并发读写方面的改进?

【在 j*****n 的大作中提到】
: partitioning will definitely improve the performance.
: specially if the partition(s) hold only the records that will be deleted,
: then the delete action will take no time via dropping the partition(s).

avatar
c*d
89
除非你知道每个range在哪个block上

【在 B*****g 的大作中提到】
: 假设每个删除都删除不同的range呢?
avatar
i*a
90
I think mainly the time is spend on i/o. But can't tell without a perfmon
trace.

[发表自未名空间手机版 - m.mitbbs.com]

【在 B*****g 的大作中提到】
: 假设每个删除都删除不同的range呢?
avatar
B*g
91
他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
以独立

【在 y****w 的大作中提到】
: 并发delete总是要受影响的吧。各个并发之间必须有严格的界限,不然以set的无序特
: 性,跑跑就锁死了,或操作旧数据了。
: lz这个没table partition,用partition/order by硬排序出来或许行,用rank避免最
: 后那组值的随机性.
: 没注意sql 2008支持不支持类似currently committed语义。

avatar
B*g
92
server上很多CPU的

【在 i****a 的大作中提到】
: I think mainly the time is spend on i/o. But can't tell without a perfmon
: trace.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
B*g
93
zkss

【在 c*****d 的大作中提到】
: 除非你知道每个range在哪个block上
avatar
i*a
94
Not cpu. I'm refering to disk i/o.
Without optimizing query, most likely the bottle neck is at i/o. Running
mulitple instances of the query wouldn't help if they all wait for the disk.

[发表自未名空间手机版 - m.mitbbs.com]

【在 B*****g 的大作中提到】
: server上很多CPU的
avatar
B*g
95
这个table显然是需要partition,哈哈

【在 j*****n 的大作中提到】
: partitioning will definitely improve the performance.
: specially if the partition(s) hold only the records that will be deleted,
: then the delete action will take no time via dropping the partition(s).

avatar
B*g
96
多几个SQL就把Disk搞死了,呵呵

disk.

【在 i****a 的大作中提到】
: Not cpu. I'm refering to disk i/o.
: Without optimizing query, most likely the bottle neck is at i/o. Running
: mulitple instances of the query wouldn't help if they all wait for the disk.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
y*w
97
lz这个瓶颈我认为是因为batch size太小带来的循环冗余开销。原先那个sql跑起来估计机器的
cpu/io都不能真正忙起来,但换个角度过来说,总体cpu/io比一次删除的要多了n多倍。
他那个表有400M rows,是个大型库,机器应该差不到哪里去,日志配置应该也不会太
小气。删10M记录应该比做1000次每次10000条要快的多,lz的要求也就是提高一半,改
下batch size应该够用了。lz应该试试然后贴个结果上来。

Running
the
disk.

【在 i****a 的大作中提到】
: Not cpu. I'm refering to disk i/o.
: Without optimizing query, most likely the bottle neck is at i/o. Running
: mulitple instances of the query wouldn't help if they all wait for the disk.
:
: [发表自未名空间手机版 - m.mitbbs.com]

avatar
B*g
98
这个需要测试,据俺测试oracle9i,一般来说1w和10w差不多。另外lz的code为啥要
hardcode 10000很多次?

估计机器的
倍。

【在 y****w 的大作中提到】
: lz这个瓶颈我认为是因为batch size太小带来的循环冗余开销。原先那个sql跑起来估计机器的
: cpu/io都不能真正忙起来,但换个角度过来说,总体cpu/io比一次删除的要多了n多倍。
: 他那个表有400M rows,是个大型库,机器应该差不到哪里去,日志配置应该也不会太
: 小气。删10M记录应该比做1000次每次10000条要快的多,lz的要求也就是提高一半,改
: 下batch size应该够用了。lz应该试试然后贴个结果上来。
:
: Running
: the
: disk.

avatar
y*w
99
随手的脚本写法,保证能删光,又不想费事儿去搞到精确的批次,要不加个@@rowcount
=0跳出来也就行了。

【在 B*****g 的大作中提到】
: 这个需要测试,据俺测试oracle9i,一般来说1w和10w差不多。另外lz的code为啥要
: hardcode 10000很多次?
:
: 估计机器的
: 倍。

avatar
y*w
100
这么多的行删除,需要的行锁太多; 如果锁升级的话影响怎样,页锁/表锁会破坏本来sql语句之间的
隔离?。 sql server没那么熟,不好说。

【在 B*****g 的大作中提到】
: 他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
: 以独立

avatar
B*g
101
等待大牛中

sql语句之间的

【在 y****w 的大作中提到】
: 这么多的行删除,需要的行锁太多; 如果锁升级的话影响怎样,页锁/表锁会破坏本来sql语句之间的
: 隔离?。 sql server没那么熟,不好说。

avatar
a9
102
先把不重要的索引删掉。

【在 b**a 的大作中提到】
: Now we can only delete them in 1 hour. How to make it in 30 mins?
: Thanks,
: Ming
: Update:
: Tried all i can except partitioned table. We cannot drop the index and rebuild it because other hourly sql job is going to insert a lot of records in the same table. Seemed no way to ensure it will finish in 30 mins so my solution is to add a waitfor delay 0.2 in every loop. In this way, the delete will finish much longer (2:30) but it will not affect any other jobs.

avatar
c*d
103
假如你run 10个batch,这些batch都在修改同一个db block or db page

【在 B*****g 的大作中提到】
: zkss
avatar
c*d
104
时间字段上的range ---逻辑
data blocks range ---物理
一般情况下是不会一一对应的
很可能一个block上有今天的数据,也有100年以前的数据

【在 B*****g 的大作中提到】
: 他那个有时间range,可以人为地分成几个range,sql其实是不同的,数据相互间就可
: 以独立

avatar
y*w
105
数据量小时行锁就行了。lz这个行锁肯定不够用,要上页锁甚至表锁。看dbms具体实现lock wait
的时间可能差很多。 逻辑上独立这个前提就有可能导致实现上的优化。所以我说还是得真懂sql
server的来说说sql server目前以及可预期版本的实现。
再说今天很对的东西,过几年也许就变成错的了。

【在 c*****d 的大作中提到】
: 时间字段上的range ---逻辑
: data blocks range ---物理
: 一般情况下是不会一一对应的
: 很可能一个block上有今天的数据,也有100年以前的数据

avatar
B*g
106
同一时间在一起的可能性很大。LZ每次就锁1w个,delete01也许会lock delete02、03
,但总不会把02-10(假设开10个)都lock住吧。当然,对SQL server的lock不是很精
通,期待大牛详解SQL server Lock。另外如果SQL搞不定,可以考虑hibernate。

【在 c*****d 的大作中提到】
: 时间字段上的range ---逻辑
: data blocks range ---物理
: 一般情况下是不会一一对应的
: 很可能一个block上有今天的数据,也有100年以前的数据

avatar
c*d
107
“同一时间在一起的可能性很大”,未必,看应用
OLTP一个block上什么时间的数据都会有

03

【在 B*****g 的大作中提到】
: 同一时间在一起的可能性很大。LZ每次就锁1w个,delete01也许会lock delete02、03
: ,但总不会把02-10(假设开10个)都lock住吧。当然,对SQL server的lock不是很精
: 通,期待大牛详解SQL server Lock。另外如果SQL搞不定,可以考虑hibernate。

avatar
c*d
108
我没搞清楚lz是必须用sql delete的方法来删除
还是可以用其他方法来实现?
avatar
B*g
109
据说hibernate比SQL快

【在 c*****d 的大作中提到】
: 我没搞清楚lz是必须用sql delete的方法来删除
: 还是可以用其他方法来实现?

avatar
y*w
110
这sql得写多烂?

【在 B*****g 的大作中提到】
: 据说hibernate比SQL快
avatar
b*a
111
yes we have to do it in sql.

【在 c*****d 的大作中提到】
: 我没搞清楚lz是必须用sql delete的方法来删除
: 还是可以用其他方法来实现?

avatar
y*w
112
have you tried bigger batch size? start with 1M.

【在 b**a 的大作中提到】
: yes we have to do it in sql.
avatar
b*a
113
Log drive does not have that big space...
Thanks.
Ming

【在 y****w 的大作中提到】
: have you tried bigger batch size? start with 1M.
avatar
j*7
114
那个Delete语句可以这么写:
DELETE TOP(10000) FROM Transactions
WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
Not sure if it's faster. The "select *" is bad in my eyes.
avatar
b*a
115
http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-
According to that link, that is faster actually than delete directly...

【在 j*******7 的大作中提到】
: 那个Delete语句可以这么写:
: DELETE TOP(10000) FROM Transactions
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
: Not sure if it's faster. The "select *" is bad in my eyes.

avatar
y*w
117
应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
差别才对,假如sql optimizer没干傻事的话。

【在 j*******7 的大作中提到】
: 那个Delete语句可以这么写:
: DELETE TOP(10000) FROM Transactions
: WHERE TransStartTime >= @FromDate and TransStartTime < @EndDate
: Not sure if it's faster. The "select *" is bad in my eyes.

avatar
B*g
118
顶,tuning就是调试

【在 y****w 的大作中提到】
: 应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
: 差别才对,假如sql optimizer没干傻事的话。

avatar
t*3
119
用TRUNCATE
avatar
b*a
120
This is a variation from this article. Sounds very reasonable so I did not
do test.
Plus i do not have enough space and data in our dev platform to test so...
I am not a sql guy...

【在 y****w 的大作中提到】
: 应该测试下,网上错的东西太多了,昨天对的今天也许就错了。这两种应该几乎没什么
: 差别才对,假如sql optimizer没干傻事的话。

avatar
B*g
121
加入CINAOUG,你也可以成为sql guy

【在 b**a 的大作中提到】
: This is a variation from this article. Sounds very reasonable so I did not
: do test.
: Plus i do not have enough space and data in our dev platform to test so...
: I am not a sql guy...

avatar
g*l
122
建一个一模一样的TABLE名字是TABLE_TEMP,注意PK, INDEXES, BULK INSERT(或者BCP)你想留住
的RECORD INTO TABLE_TEMP,DROP OLD TABLE, RENAME TABLE_TEMP TO TABLE,
RECOMPILE TABLE,没做好INDEX,又没弄PARTITION的,只嫩用这种方法
avatar
s*o
123
试过disable index, 然后 rebuild 么?不是drop index
avatar
g*l
124
没有INDEX不删的更慢么,DELETE WHERE上要有INDEX,然后BATCH的删
avatar
s*o
125
是的,只留要用的index. 要是删除很多record,还不如重建一个table放不删的数据快

【在 g***l 的大作中提到】
: 没有INDEX不删的更慢么,DELETE WHERE上要有INDEX,然后BATCH的删
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。