免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: 2BeSybPro
打印 上一主题 下一主题

Sybase中大的update一定要用小批量(small batch size) - 附例子 [复制链接]

论坛徽章:
0
11 [报告]
发表于 2013-01-29 16:25 |只看该作者
請教一個問題,修改表名後一定要重建存儲過程嗎?
用sp_recompile重新編譯一下可不可以?

论坛徽章:
0
12 [报告]
发表于 2013-01-29 22:35 |只看该作者
baiynije 发表于 2013-01-29 16:25
請教一個問題,修改表名後一定要重建存儲過程嗎?
用sp_recompile重新編譯一下可不可以?


Procedures and triggers that depend on an object whose name has been changed work until they are dropped and re-created.


1> create table test(id int, name varchar(20))
2> go
1> insert into test values(1,'baiynije')
2> go
(1 row affected)
1> select * from test
2> go
id          name
----------- --------------------
           1 baiynije

(1 row affected)
1> create procedure test_proc
2> as
3> select * from test
4> go
1> exec test_proc
2> go
id          name
----------- --------------------
           1 baiynije

(1 row affected)
(return status = 0)
1> sp_rename test,test_tbl
2> go
Object name has been changed.
Warning: Changing an object or column name could break existing stored procedures, cached statements or other compiled objects.
(return status = 0)
1> sp_recompile test_tbl
2> go
Each stored procedure and trigger that uses table 'test_tbl' will be recompiled the next time it is executed.
(return status = 0)
1> exec test_proc
2> go
Msg 208, Level 16, State 1:
Server 'xxxxx', Procedure 'test_proc', Line 3:
test not found. Specify owner.objectname o

论坛徽章:
0
13 [报告]
发表于 2013-01-30 16:37 |只看该作者
2BeSybPro 发表于 2013-01-29 22:35
Procedures and triggers that depend on an object whose name has been changed work until they are ...

謝謝,可能是我沒說清楚,
我的意思是假如有個表test1 ,該表出現問題,我想建一個新表來替代它
如select * into test2 from test1 where ...
然後將原test1 改為其它名字,test1_old
再將test2 改為test1,此時使用到test1的存儲過程應該不用刪除重新建立吧?

论坛徽章:
0
14 [报告]
发表于 2013-01-30 22:46 |只看该作者
baiynije 发表于 2013-01-30 16:37
謝謝,可能是我沒說清楚,
我的意思是假如有個表test1 ,該表出現問題,我想建一個新表來替代它
如selec ...


是的,直接用sp_recompile就行,可以不用删除重建procedures/triggers。以前v12.5 sp_recompile不能解决跨库引用表名变更,v15可以了。

论坛徽章:
0
15 [报告]
发表于 2013-01-31 08:55 |只看该作者
2BeSybPro 发表于 2013-01-30 22:46
是的,直接用sp_recompile就行,可以不用删除重建procedures/triggers。以前v12.5 sp_recompile不能解决 ...

謝謝,還想請教一個關於reorg rebuild 的問題,
就是在平時的維護中需要定時去用reorg rebuild重建表嗎,之前做時出現一個問題,就是當某個表有問題時,執行reorg rebuild 後有問題的數據就直接刪除了,以至後來不敢隨便使用了,rebuild之前是不是要用dbcc 檢查一下數據庫?另外有些表比較大,有幾千萬條的數據,這種表要如何去維護?目前我是只rebuild 索引或只更新索引統計信息,還請指教。

论坛徽章:
0
16 [报告]
发表于 2013-01-31 23:56 |只看该作者
baiynije 发表于 2013-01-31 08:55
謝謝,還想請教一個關於reorg rebuild 的問題,
就是在平時的維護中需要定時去用reorg rebuild重建表嗎, ...


Reorg rebuild table以前有个版本(记得是v12.0)会掉数据,这个bug已经被修复了。注意reorg rebuild table会放exclusive table lock(v15.7有所改进,做到了部分online reorg),如果是业务关键表会导致系统不可用;而且reorg rebuild table要求打开"select into" option和有足够大的free space (same size as the table and its indexes)。因为fragmentation主要在index上,用reorg rebuild index/update statistics 就好了,reorg index holds ex_intent lock, 不会导致severe blocking。

这方面的日常维护:
1. weekly dbcc checks
2. weekly reorg rebuild index (you can include reorg compact if necessary)
3. daily update statistics

如果你的系统不是24x7,可以在周末做reorg rebuild table;否则的话,就只有找个window做年度reorg table.

论坛徽章:
0
17 [报告]
发表于 2013-02-01 13:52 |只看该作者
2BeSybPro 发表于 2013-01-31 23:56
Reorg rebuild table以前有个版本(记得是v12.0)会掉数据,这个bug已经被修复了。注意reorg rebuild tab ...


非常感谢!
我们的系统是7*24的,只能找一些全体放假的时候才能做rebuild了,还有因为数据库空间有限,一些大的表很难去做rebuild,希望sybase 在这方面有所改进。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP