Tip: 看不到本站引用 Flickr 的图片? 下载 Firefox Access Flickr 插件 | AD: 订阅 DBA notes -- ![]()
2009-01-07 Wed
Shared by Oliver Ding
"——每个人都应该读一读这本书。它是一部对现代和未来社会的“ORACLE”。
在我读过的书中,可以说,没有一本能像《失控》这样引起我的共鸣,使我能籍以印证过去所学所得以及所经历的,并指导我未来的旅程。
Kevin Kelly 先生的这本书出版于1994年。那时,我正在大学里读书,学的是控制。3年后,复杂理论在国内的学术圈中着实风靡了一阵。虽然热潮很快就退了下去,但其理念和信条已经在我的头脑深处播下了种子。"
——每个人都应该读一读这本书。它是一部对现代和未来社会的“ORACLE”。
在我读过的书中,可以说,没有一本能像《失控》这样引起我的共鸣,使我能籍以印证过去所学所得以及所经历的,并指导我未来的旅程。
Kevin Kelly 先生的这本书出版于1994年。那时,我正在大学里读书,学的是控制。3年后,复杂理论在国内的学术圈中着实风靡了一阵。虽然热潮很快就退了下去,但其理念和信条已经在我的头脑深处播下了种子。
再3年,我去南加州大学读书,转学运筹。上的第一门课是讲规划(scheduling & planning)。授课教师是一位在工业界做了很多年咨询服务,一直做到退休还在做的老人。第一节课,他就开宗明义:“很多时候,我们要做的是找到一个可行规划,而不是最优规划;你脑中冒出的第一个直觉规划,往往就是一个好的可行规划。”那时,听到这话的我,自恃有一些数学功底,很是不以为然——运筹运筹,讲的就是最优化理论;教授的这些话,只不过是工业界那些没有数学底子、求不出最优解的家伙们给自己的一个借口而已。
又3年,我进入 Oracle,成为一名应用工程师,主要做库存优化产品及其相关领域的研究。虽然最终无法接受工业界流行的潜规则——“When you can’t fix a bug, you turn it into a feature”,但在工业界的实践,却让我逐渐理解了什么是“好的可行解”,以及“优化是有成本的”这一概念。
再3年,开始做译言。这是我第一次真正地接触互联网——在此之前,我对互联网的理解仅仅限于 Google 和 BBS。Web2.0,维基,大众的智慧,……,这些名词和概念,都是在做译言后恶补起来的。做了两年多后,我想,我们逐渐找到了译言最核心的价值——社会化协作。
做译言的过程,也是我将所学的控制、优化等知识和理论以及在工业界的实践经验,不断地印证对照、融会贯通和否定之肯定的过程。形成了如下观点:
关于简单:
- 数学的美在于简单
- 复杂系统源于简单规则
- Everything should be made as simple as possible, but not simpler. — Einstein
关于优化:
- 优化是有成本的
- 很多时候,我们追求的是可行解,而不是最优解;可行解往往不是通向目的的最短路径
- 可行解的选择并非唯一,往往没有绝对的优劣,顺势利导是选择的原则
- 可行解是动态的,不断变化的
- 有些时候,不同的可行解之间边际效益会相差巨大,这时,就需要尽最大努力推动边际效益明显的可行解
关于控制:
- 局部的、小范围的控制,可以也应当做到精确的闭环控制
- 全局的、大范围的引导,往往是开环或半开环的,是基于规则的
关于做事:
- 择善而固执,循序而渐进
最后,将《失控》这本书的全书要义——九律——贴在这里。前面,我一直在说我自己的体会;除了开头,只字未提《失控》。不过,我相信如果你读了下面的九律,就会明白,我在前面所说的,早已包含在《失控》里了。。。
The Nine Laws of God
- Distribute being
- Control from the bottom up
- Cultivate increasing returns
- Grow by chunking
- Maximize the fringes
- Honor your errors
- Pursue no optima; have multiple goals
- Seek persistent disequilibrium
- Change changes itself
我没有将“九律”译成中文,因为现在还没有合适的译法。也希望每一位“你”,能以协作的方式,为“九律”贡献最精采的翻译。
Shared by Robert Mao
你在天朝这么有主人翁意识地折腾的话,肯定会被和谐了。
高震东先生演讲稿-足以震惊所有的中国人[转载]
--------------------------------------------------------------------------------
台湾有这么一所学校,学生年龄在15-18之间,每年三千多学生中,因违反校规校纪被校方开除的二、三百人。学校没有工人,没有保卫,没有大师傅,一切必要工种都由学生自己去做。学校实行学长制,三年级学生带一年级学生。全校集合只需3分钟。学生见到老师七米外要敬礼。学生没有寒署假作业,没有一个考不上大学的。这就是台湾享誉30年以道德教育为本的忠信高级工商学校。在台湾各大报纸招聘广告上,经常出现"只招忠信毕业生”字样。
以下是校长高震东在国内的讲演:
同学们,你们说“天下兴亡”的下一句是什么?(台下声音:“匹夫有责”)──不,是“我的责任”。如果今年高考每个人都额外加10分,那不等于没加吗?“天下兴亡,匹夫有责”等于大家无责。“匹夫有责”要改成“我的责任”,我是这样教我的学生的。所以说,现在我们大陆教育办得不好,是我高震东的责任,只因为这样,我才回祖国专门举办道德方面演讲。(掌声)“以天下兴亡为已任”是孟子思想。
禹是人,舜是人,我也是人!他们能做到的,我为什么不能呢? “天下兴亡,我的责任”,唯有这个思想,我们的国家才有希望。我们每个学生如果人人都说:学校秩序不好,是我的责任;国家教育办不好,是我的责任;国家不强盛,我的责任……人人都能主动负责,天下哪有不兴盛的国家?哪有不团结的团体?所以说,每个学生都应该把责任拉到自己身上来,而不是推出去。我在台湾办学校就是这样,如果教室很脏,我问“怎么回事?”假如有个学生站起来说:“报告老师,今天是32号同 学值日,他没打扫卫生”。那样,这个学生是要挨揍的。在我的学校,学生会这样说:“老师,对不起,这是我的责任”,然后马上去打扫。灯泡坏了,哪个学生看见了,自己就会掏钱去买个安上,窗户玻璃坏了,学生自己马上买一块换上它──这才是教育,不把责任推出去,而是揽过来。也许有些人说这是吃亏,我告诉你,吃亏就是占便宜,这种教育要牢牢记在心里,我们每个中国人都要记住! 学校更应该训练学生这种“天下兴亡,我的责任”的思想。校园不干净,就应该是大家的责任。
你想,这么大的一个校园,你不破坏,我不破坏,它会脏吗?脏了之后,人人都去弄干净,它会脏吗?你只指望几个工人做这个工作,说:“这是他们的事。我是来读书的,不是扫地的。”──这是什么观念?你读书干什么?读书不是为国家服务吗?眼前的务你都不服,你还能为未来服务?当前的责任你都不负,未来的责任你能负吗? 水龙头漏水,你不能堵住吗?有人会说:“那不是我的事,那是总务处的事。”这是错误的。一般人最坏的毛病是这样:打开水龙头后,发现没水,又去开第二个,第二个也没有,又去开第三个──这样的学生,在我学校是要被开除的!连举一反三都不懂,第一个没水,第二个会有吗?你就没想到水会来吗?人无远虑怎么能行?作为一个干部,作为一个人,都要想到后果,后果看得越远的人,越是一个成功的人。一个只管眼前,不顾将来的人,不是一个好干部,不是一个有用的人。水管不关,来了水后让它哗哗哗满池子去流,仍不去关注:“反正是国家的水,不是我的自己的!”──浪费国家的,就是“汉*”!你为什么浪费国家的水?你为什么浪费国家的资源?我每天洗脸都为国家省一盆水,一年省多少水,你算算,你们学校六千多学生,每个每天节省一盆水,一年省多少水?省水就是省电,就是节省国家资源。爱国可有两种,一种是积极爱国,一种是消极爱国。积极爱国是为国家创造财富,消极爱国是为国家节省财富。国家用那么多百姓的民脂民膏来供你读书,你还浪费国家的财富,你良心在?你上大学都如此,怎么能期望于中学生、小学生呢?怎么能期望于一般老百姓呢?你高级知识分子都不爱国,怎么能让老百姓去爱国呢?从自己身边做起,我们国家才有希望──这就是“ 天下兴亡,我的责任”积极负责的道德观念,这就是道德教育。
另一点,我们要有“勿以善小而不为,勿以恶小而为之”的敬业观念。天下有大事吗?没有。但任何小事都是大事。集小恶则成大恶,集小善则为大善。培养良好的道德,是从尊敬老师开始的,是从那很小很小的事开始的。这种道德是慢慢建立起来的,而不专门找到大事才干。今天上午下课的时候,我和师大校长一块出来,礼堂里有很多废纸。我说不要捡,要等下午学生自己捡──同学们,谁丢下这些纸屑就是不爱国。天下无大 事,请先把自己脚下的纸屑捡起来──这就是我的教材”。好的,同学们捡起自己脚下的废纸,这就爱国的开始。我给大家讲两个关于渍纸的故事。
第一个,美国有个“福特公司”,福特是一个人,他大学毕业后,去一家汽车公司应聘。和他同应聘的三四个人都比他学历高,当前面几个人面试之后,他觉得自己没有什么希望了。但既来之,则安之。他敲门走进了董事长办公室,一进办公室,他发现门口地上有一张纸,弯腰捡了起来,发现是一张渍纸,便顺手把它扔进了废纸篓里。然后才直到董事长的办公桌前,说:“我是来应聘的福特。”事长说:“很好,很好!福特先生,你已被我们录用了。”福特惊讶地说:“董事长,我觉得前几位都比我好,你怎么把我录用了?”董事长说:“福特先生,前面三位的确学历比你高,且仪表堂堂,但是他们眼睛只能“看见”大事,而看不见小事。你的 眼睛能看见小事,我认为能看见小事的人,将来自然看到大事,一个只能“看见”大事的人,他会忽略很多小事。他是不会成功的。所以,我才录用你。”福特就这样进了这个公司,这个公司不久就扬名天下,福特把这个公司改为“福特公司”,也相应改变了整个美国国民经济状况,使美国汽车产业在世界占居鳌头,这就是今天“美国福特公司”的创造人福特。大家说,这张废纸重要不重要?看见小事的人能看见大事,但只能“看见”大事的人,不一定能看见小事,这是很重要的教训。
第二个渍纸的故事,当本届亚运会在日本广岛结束的时候,六万人的会场上竟没有一张废纸。全世界报纸都登文惊叹:“可敬,可怕的日本民族!”就是因为没有一张废纸,就使全世界为之惊讶。再看看我们十月一日天安门广场升国旗的镜头,当人们散去,满地废纸,到处乱刮!外国人一看当然会这样认为:你们中国此时要同日本比,差得远呢!大家不要总是说:我们国家地大物博,有137枚金牌──这都没用,咱们的道德水准还没上来,还差得远!大家说这些废纸重要不重要?所以说,我让大家捡起一张废纸,这就是爱国的开始。万事从小事做起。美国太空3号快到月球了,它却不能登上去而无奈地返回来,为什么?只是因为一节30块钱的小电池坏了,他们这个酝酿很久的航天计划被破坏了,几亿元报废了!天下有大事吗?大家看哪次飞机失事是翅膀和头一齐掉下来的?都是一节油管不通,一个轮胎放不下来才失事的。一个人的死,哪个是全身完全溃烂死掉的?都是肝坏了,或心脏有毛病,等等一个小器官不正常而死的!──同学们,从现在开始,你们要有敬业观念。我们中国实行九年制教育目的就是这样,就是要看你怎样同老师相处,怎样与朋友相处,这就是教育的目的。从古至今,中国的教育才是最伟大的教育,你把西方的教育看作是最先进的教育,那就大错特错了。美国的教育部长三个月前发表讲话说:“我们国家的教育是彻底失败的,我们把人教成了肉机器,我们要向东方学习人文教育!”所以说,我们祖国的教育是世界上最伟大的教育!(掌声)孔子告诉我们:学而不思则罔,思而不学则殆。一个学生要不断地学,不断地想,不断地做,这就是真正教育,这就是中国教育精髓所在。
再一个,我们要进行吃中国饭、说中国话、过中国节和穿中国服装的振兴民族文化的道德教育。一个中国人连中国饭都不吃了,能叫中国人吗?吃中国饭的第一代表是使用筷子。筷子原是中国的文化,是文明的行为。我去美国,偶尔吃他们的西餐,他们一上西餐我就说:“请给我拿筷子来。”他们问我:“吃西餐都用刀*,你为什么用筷子?”我说筷子是文明的象征,而你们的刀*是野蛮标志,所以我不用。筷子可切、可*、可削、可夹、可戳,无所不能,而你们的刀*笨重至极,象杀人的武器。(掌声)学生要吃烧鸡,我说可以,如果他说要吃“肯炸鸡”,我要揍他,他说吃面包夹豆腐乳,可以,他说吃“汉堡”却不可以。你可以吃碉堡,但不能吃“汉堡”。这就是中国的民族精神教育!外国只是机器、枪炮比我们强,吃的能与中国比吗?吃外国人的东西只是种怪心态,可卑啊!
我们学校的英文教学是全台湾最好的。我从美国请来两名老师,专门教我的学生学说外语。我有一个留美班,他们一定是要留美的。但是他们所学的教材第一页上都印着我的话:“中国人学英文是我们的国耻行为,学英文是中国最可悲的行为,但我们不能不学,因为别人超过了我们,“敌人”枪炮、科学压过了我们。今天我们必须学习他们的科学,然后才能打倒他们!超过他们!我们要以夷制夷!非把英文学好不可,所以要咬牙切齿学英文!(掌声)我们学英文目的并不是为了去美国洗盘子刷马桶,去伺侯外国人,去做丢尽祖宗八辈人的事!”(掌声)所以,我的学生英文学得都非常好。如果一个英文老师一上课就说:“同学们,今天我们要学英文了。英文是世界语言,是世界上最美的语言!一个不会英文的民族是一个低等民族,英文太美了!太棒了!”你说这个老师要不要打屁股?所以我总是告诉这些老师:要好好教我的学生,你不要替外国人宣传,变成“汉*”!要告诉学生雪耻图强,打败列强,这是中国人的希望(掌声)!
你们这里不也有英文老师吗?外语系的学生以后不也去教英文吗?上课以前你们要对学生进行爱国学英文的教育,不要上来就替外国吹一场,你们不要认为:传道者只是传英文之道、授英文之业,而要传爱国之道,授英文之业。好,同学们懂得了这些道理,下一步我们就要知道,我们今天的教育是很失败的。因为,我们从小就被教错了。所以,我们要进行为国家而求学问,为社会分工而学技能利他、利群的道德教育。大家先要想想为什么读书,为谁读书?你们要反思一下。有些人也许会说,为自己找个饭碗而读书!这是多么卑鄙和渺小,多么无聊和可怜!你绝对不应该单是为找个饭碗而活着!找个饭碗吃饭太简单了! 拿个刀子,找个人随便捅一下,绝对一辈子有了饭吃,而且还有人伺侯,还有人为你做饭,睡觉时还有人为你站岗,你的东西一样少不了!那不就解决吃饭了吗?你为什么不干呢?因为我告诉了你,要学好生存的技能,要懂得生命的意义和价值,那里不是创造人类价值的地方!所以,我们要知道读书绝对不是为了自己,读书是为了国家而求学问,所以,我们要告诉孩子们读书、做事要确定一个方向:先做自己应该做的事,再做自己喜欢做的事。很多人为兴趣而读书,岂有此理!读书有什么兴趣?真正目标不应是兴趣,而是责任,在责任当中找到兴趣,但不能用兴趣代替责任。越在黑暗中越做光明的事,这就是道德教育。我们读书是为了国家。同学们,你们想想你们从小受到什么教育?尤其是农村子弟,你爹妈是怎么教你的?他们这样告诉你:你要好好念书!你不好好念书,将来就不能出人头地,你必须努力奋斗好好读书,>你才有前途,读书是为了你的幸福,读书是为了你的前途!读书一切是为了你!你就是在这种教育下长大的,这就是最错误的教育,这就是最糟糕的教育!所以小孩子长大以后就知道,啊哈,读书就是为了我呀,与任何不相干,为了我的前途,为了我的未来,为了我的希望,你看这个国家还有希望吗?它与国家毫不相干!他喝着国家的奶水,用着国家纳税人的钱,拿民脂民膏培养出的却是一个自私自利的小孩,培养出一批自私自利的老师,你想:这国家会有前途吗?你读书的方向都错了,读书不是为了自己,读书是为了我们的国家,国家需要人才,国家需要干部,国家需要建国的栋梁。国家为什么培养你?国家是欠你的吗?你能白白吃国家的饭吗?白白享受这里的宿舍和餐厅、白白地享受老师对你知识的传授吗?你凭什么?你对国家有什么贡献?你对社会有什么贡献?有什么牺牲?你一切都没有,你只是个造粪的机器而已。你每天吃饭了,无所事事,你对国家有什么贡献?国家在期盼着你的贡献,期盼着你的未来,因为有一天你会长大,有一天你会学成,你要为国家做事,所以国家才在你身上投资,让你为国效命。因为道德教育必须以国家教育为前提,所以今天我们要爱我们的国家。正好你们是读师大的,你们在三、四年之后要培养跨世纪的接班人,你的责任比谁都大。如果你都没有国家观念,你都不爱国,你怎么要求你的学生爱国呢?所以说今天的老师是最重要的。这就是我跑来跑去,为师范生灌输爱国思想的原因所在!你们爱国,学生自然爱国!如果不爱国,天天发牢骚,天天想转行,天天想下海,那下一代还有什么希望?尤其是学英文的,总想好好学,将来以后到哪个公司为哪个老板、哪个董事长当翻译官,多丢脸!多没人格,多没气度!(掌声)我这里特别强调的是国家观念。
我常常给我的学生讲一个故事:我们有一天出去旅行,忽然间暴风雨来了。我们没地方避风躲雨,孩子们向前跑,一看前面有个草棚,大家“哗”地冲了进去,一冲进去大雨就来了。大家好高兴,“哇,今天运气不错哟,刚刚找了房子大雨就来了。太快乐了!”大家也不顾虑房子干不干净,有没有人住过,只要有避雨的地方就很满足了。但这个房子在风雨中突然间要倒塌,同学们想尽办法“扶住它,不能让房子倒塌”。在这种状况下,我很有感慨,同学们,你们说是我们需要房子呢,还是房子需要我们呢?(掌声)我看是我们需要这座房子。这座房子就是我们的国家,再破再烂是我们的家,再穷再破,是我们的家,我们要爱她!(掌声)你怎么可以羡慕外国人呢?“唉呀,你看外国人多好!我不当中国人,我想当外国人!”那是不对的。我们国家不如别人,我们承认,但是我们有决心,我们会慢慢把它搞好,但我们一定要牺牲自己,有热爱国家的观念。人人在砍国家、吃国家、拿国家,这个国家怎么会好呢?人人都贪污、腐败,这国家会好吗?外国有个加拿大!中国有个“大家拿”,再大的国家也会被你拿穷了。(掌声)我走到哪里,绝对拒绝招待。我走到哪里吃自己,用自己,坐你的汽车给车钱,住你的旅馆给你旅馆钱,吃你的饭给饭钱,绝对不沾国家一毛钱。我就是要做个示范给你看!(掌声)什么叫爱国,是我们把东西把钱把命给国家,这叫爱国,你总是把国家的东西往家拿,这叫什么爱国?有些人偷国家、拿国家,>还拿得津津有味,拿得大言不惭,拿得毫不要脸,这怎么得了?(掌声) > 有人说:老师,你让我爱国,我可以爱国,不过,国家在哪里?我找不着!“不识庐山真面目,只缘身在此山中。”你在国家里头,不知国家在哪。当老师的,国家就是你面前的学生。你往讲台上一站,下边的学生就是你的国家,找国家太容易了。今天我往这儿一站,下面1500人就是我的国家,我必须对你们尽心尽责,就要产生教化作用,影响作用,你就是我的国家,我爱你,就是我爱国,把我的思想传播给你,就是爱国!(掌声)那你以后往你的学生面前一站,那就是你的国家。你不能浪费他的时间,他的生命,你要好好为国家培养下一代,你给他这种爱国思想,你就是一个爱国者,不给他,你就是不爱国,你就是叛国者!(掌声)同学们,将来你也有留学的机会,你要注意到,不要让自己丢了中国人的脸。你别去了不回来,这丢中国人的脸呢!外国人是不会看得起你的。他们会说:你看,这些留学生一点国家观念都没有,这些小亡国奴!人家怎么会看得起你呢?这很丢脸,是很难为情的一件事。
国家对我们来说非常重要,你不到国外不知道“祖国”的重要。一个没有国家的,一个国势很弱的人,实在是太可怜了!太可悲了!所以,我们今天的中国人要自强、自爱,我们要知道爱我们的国家。国家不壮大,你个人再有钱有什么用?再有地位有什么用?你永远不受人尊敬啊!
我今天讲了什么是爱国主义,哪里是爱国主义,处处都是爱国主义!任何一个行为都可以爱国。大家都知道以色列与阿拉伯的战争。阿拉伯和以色列打仗打得正热闹的时候,世界正举行选美比赛,那年以色列小组正好当选“世界小组”。许多电影界的人士都围着她:“小姐签约吧,将来你可以发大财了”,“签约后你名利双收,你何必回国呢,你的国家正在打仗,那么一个小国,随时会被吃掉的!”“你回去多可怕!你现在又有钱,又有名,留在美国吧!”这姑娘却在电视上发表谈话:世界小姐不是我个人想选,我只是让你们知道,以色列是一个优秀的民族,所以我出来竞选。我想让人们知道:地球上有以色列这个国家,所以我要出来竞选。我今天被选上了,就完成我的任务,我也告诉世界:以色列是个优秀的民族,因为我是世界上最漂亮的女人,同时还告诉世界:以色列这个国家正艰苦奋战,希望全世界的人民同情我们,支持我们!支持我们国家的独立!现在我的国家正在打仗,要钱何用?我们以色列亡国两千年,因为我们文化不亡,所以我们还能建国。今天我要回去,为祖国而战,要钱何用?--她发表完这番谈话,第二天就坐飞机回国了。(掌声)这个消息发表后,全世界的人对以色列刮目相看!哇,以色列人真了不起啊!于是,以色列的军队,军心大振,他们象疯了一样,把阿拉伯的军队打得干干净净!这就是历史上最伟大的七日战争!七天打完!这就是因为一个女孩子的一句话!
所以,同学们,爱国常常在一个微小的地方。“一言以丧邦,一言以兴邦”。我们是受过高等教育的,我们肩负着国家的荣辱啊,人家看到我们就看到国家的希望。同学们,国家的前途是向后看的,个人的前途是往前看的。老师这样一回顾,就知道二十年以后的中国是什么样子,看看小学生就知道三十年后的中国是什么现象。如果他品德良好,道德高尚,爱国,二十年后国家就有希望。如果看见这个小朋友很爱国,很有礼貌,很有道德,那么三十年后的中国人是了不起的中国人。否则看着他怠惰、自私、傲慢、无礼、没有水准,就知道三十年后的中>国就是那个样子。我们今天要雪耻图强,力争做得更好。不要丢了祖宗的脸,不要丢了我们汉唐先烈的脸。 爱国是很具体的。我的学校门口有个标语:离开校门一步,肩负忠信荣辱。推而大之,离开国门一步,肩负全国荣辱。一口痰吐在中国是小事,一口痰吐在外国,你就丢了中国十二亿同胞的脸,因为你代表十二亿中国人,而不是你个人,你千万不要以为,“好汉做事好汉当”,你错了;你做不到;你不够资格当!所以每个同学的一言一举都要注意。高老师回到国内,看到不顺眼的要讲要骂,要批评要建议,但是我离开了大陆回到台湾,不会讲大陆一句坏话。他们问:大陆好吗?我说好得不得了!太大了,太棒了。到了美国就说中国人伟大得不得了,绝对不会丢中国人的脸,一句对中国的批评也没有。但是,回来一定要实实在在地讲话,诚诚恳恳建议。有的人刚好相反,在国内他屁都不敢放一个,装得那么温顺,那么可爱,一离开中国就大放獗词,把中国骂得一文不值,这就是标准的汉奸王八蛋也!(掌声)
2009-01-06 Tue
-- 以供 自我勉励
那些你曾经为之激动、兴奋,消耗了你无数时间和精力的事情,大多数是无足轻重的。
那些等着万事俱备才去做的事情往往永远也没机会做。
-- 立刻行动! 行动上热情!
如果大家都抱怨你说你太特例独行与别人格格不入时,你一定在正确的轨道上。
如果工作是你全部的生活,你的生活就是一项艰苦的工作。
任何一个成功的人都有失败的时候。不要企图永远占据成功者的位置。
每件事都要花费计划中两倍的时间而只得到期望中一半的成果。没必要为此沮丧,认清现实,继续前进。
无论你怎么尝试改变,你总是你自己。
世界上最响的声音就是人们的抱怨声。别再让它更响了。
原来老得翻翻文档, 找出 Label 和 GoTo的语法, 特别烦人.
这个东西实在算不上一个新特性, 只能叫作功能完善而已.
使用"CONTINUE" 的 PL/SQL程序样本, 请参考:
http://technology.amis.nl/blog/?p=2261
看来我比你幸运,从来没有考虑过copy standby db control file.
我们的配置是, 4 nodes RAC 10.1.0.4, 1 real time standby, 1 read-only standby, for reporting, refresh every night.跑了一年多了 啥问题也没有 可惜Logcial stdby 不支持宽表(100+ columns)等升级到10.2.0.3,会加一个Logical Standby.
根据我的经验,Oracle 整体稳定,但总有一些莫名其妙的Bug,我们的宗旨是: "绕过去, 别较劲"
读了一些Blog, 谈论Oracle database的下一个版本.
Oracle db 11g
Partition
(a. Time dimension and
b. Child table partition based on master tables partition columns
)
和数据压缩, 令人神往. 嘻嘻.
So I turned to Good practice:
Middle-tier DAL or Database API – Database access guideline
(Hibernate vs Store procedure)
• Maximise SQL and minimise PL/SQL
• Minimise client code and maximise database server code.
Generally servers are more powerful and built for this type of work. You also want to minimise trips back and forth to the server.
Reference:
Business Logic - PL/SQL Vs Java
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:883929178230
I prefer to put all logic that deals with data in PLSQL. There is no more natural language to interact with SQL data then PLSQL. None.
For example -- native compilation was added -- turned plsql into object code that runs natively on the OS.
Database API, build the data API in the database, you call the data API
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:25405782527721
When to use Hibernate DAL
• One step SQL (SELECT OR UPDATE) to finish your goal
• Heavy and forced interaction in mid tier, like CCBB encryption, that means high coulping too, and hard to encapsulate the process logic.
Jave developer can help us on this list.
When to use Database API and Store Procedure Package
• Complex SQL
For example, book delete check, reference Single Hash Table and list of IDs.
• Many (more than 2) steps data machinations logic in a sigle module
• Reture rows more than one page, let's say 20 rows from database.
We like Database API approach, because it:
1.. make software components modular, I'm totally into modular programming
2.. software modules must carry out a very specific task (and be very efficient at carrying it out)
3.. each software module should be loosly coupled (to limit dependencies)
4.. It removes the need for triggers as all inserts, updates and deletes are wrapped in APIs. Instead of writing triggers you simply add the code into the API. I loath triggers.
5.. It prevents people who don't understand SQL writing stupid queries.
All SQL would be written by PL/SQL developers or DBAs, reducing the likelyhood of dodgy queries.
6.. The underlying structure of the database is hidden from the users, so I can make structural changes without client applications being changed.The API implementation can be altered and tuned without affecting the client application.
7.. The same APIs are available to all applications that access the database. No duplication of effort.
Anything that generates SQL on-the-fly worries me, not just Java. I want to be able to cut and paste the SQL, not try and capture or trace it during a run.
Our concept is "build the data API in the database, you call the data API" .
Database API has been layered by different UI technologies over time.
All about API's. The applications don't do table level(select/insert/update/delete) stuff, the apps don't even really know about tables.
On top of database schema we have an API that does the data stuff.
In the application we call this API but have our own application logic as well
(only application logic is in the application, data logic is – well, right where it belongs – next to the data, waiting for the 'next great programming paradigm to come along')
The fact that our UI is in Java isn't really relevant. You could pretty much see how you would use this package from C#, Java/JSP, Swing, VB, Pro*C, Forms, Powerbuilder, a mobile phone,
–
Storing application code in the database has had it's champions and detractors.
When you start putting application code in the database, you are in the thoroughly non-portable arena. That code, were you to port your application to another database, would have to be rewritten. But think about your application mid-tier layer, will you port Java code to C#/.Net,-> Pascal -> C -> VB, then to Python, Ruby on Rail ...etc., will you do that?
Its very specificity to that database means it can also take advantage of, and wire close to that engine. There are situations where stored code in the database can be notably faster. Supposed you have to update some chunk of a million rows after doing some machinations on the data.
In a stored procedure the data is read, manipulated, and updated in one step. Meanwhile if you did the same in your middle tier application code, you would have to send that data set over the network, do your manipulations, and send it back. Not only would it make this one task slower, but other transactions vying for that same data could potentially have to wait while that data is in transit, and being manipulated. Also, stored code can serve to encapsulate specific requests which can be invaluable at simplifying your overall application. All three databases support stored procedures and functions. Oracle also supports packages, or collections of stored procedures as well as various object oriented features, which almost no one ever uses. An additional note, a database engine actually context switches between stored code, and the SQL code embedded therein. As since of 9i, Oracle introduced bulk binding, so you can do work on large sets of rows, and update them all in one go, instead of each loop iteration. This feature can even further improve performance quite dramatically.
Document the SQL access database
We'll build a small application for this target, on Oracle APEX (HTML DB).
then QA (and Developer) need to record all the SQL access db in the new developing applications.
* SQL execution path
* SQL performance statistics
我的老板(Borland J Builder 的首席构架师)总喜欢问: 啥时候换MySQL呀,要不MS-SQL 2005 也行 (整天宣传SQL-Server2005的优越性), 前两天又来了个 Enterprise DB (基于Postgres)
像我这样只懂Oracle的 咋办呀?!!(我就建议老板 试试DB2还行 我有认证)
还好-最近的统计显示Oracle市场占有率超过50%.
The idea is we may take this Opportunity to introduce a new database developer join our team.
We pay 6 months salary to the contractor and only get an actual 3 months of work since they need 3 months to get up to speed on our environment (together with the increased cost of hiring a contractor).
It’s better to give this opportunity to the new employee as a database developer which can learn our business, and then contribute to our company in long term.
Why we need a Database Developer and Database API?
Today some GUI logic is in the middle tier but most of the data logic is still in PL/SQL (let’s say eBay here).
Performance
Performance is directly connected to stability and functionality, when db node running to it’s knee and hangs, you can do nothing, and cause some potential locks and bugs.
Dodgy SQL examples.
1) Filter data in java side, treat db as a black data store.
We should always filter data from the database side, I knew it 10 years ago as a database developer.
SELECT I.*
FROM ABELISTING.XBNIDENTS I
WHERE I.PROVIDER <> 44
What we did before:
SELECT I.* FROM ABELISTING.XBNIDENTS I;
Get all the data returned from database,
And then filter the row <> 44 in Java side.
2) Cursor fetches
What we are doing:
• 1. get Max and Min xbnidentsid
SELECT MIN(XBNIDENTSID) AS MIN, MAX(XBNIDENTSID) AS MAX
FROM ABELISTING.XBNIDENTS
• 2. Split it into many 100 rows chunks by calculate each xbnidentsid range
• 3. run below SELECT many times, each run get 100 rows
SELECT I.*, R.RECOMMENDATIONSET
FROM ABELISTING.XBNIDENTS I
LEFT OUTER JOIN LIBRARYTHING.ISBNRECOMMENDATIONS R
ON I.XBNIDENTIFIER = R.ISBN
WHERE I.PROVIDER <> 44
AND I.XBNIDENTTYPECODE = 1
AND I.XBNIDENTSID < #xbnidentsidMax#
AND I.XBNIDENTSID >= #xbnidentsidMin#
It’s a nest loop join, cost 5 times more resource and latches.
Why not run a simple single SQL SELECT, hash join 2 tables, and use bulk cursor prefetch?
It’s been implementing to X-Team, the rows Prefetching.
2.1) change a simple UPDATE to 2 steps.
1) select the PK_ID by some predicates, cached into Java server side, maybe run the SQL many times, return 100 rows each time.
2) process row by row by PK_ID
Why not run a single UPDATE SQL here?
3) Treat database as a black box or a human brain; actually, we control how database works, we need to have:
• knowledge of what the database is capable of doing
• knowledge of all of the intricacies of SQL
• knowledge a solid understanding of goal- what the question is
Here is an example:
This SELECT takes 60 seconds.
SELECT MIN(XBNIDENTSID) AS MIN, MAX(XBNIDENTSID) AS MAX
FROM ABELISTING.XBNIDENTS;
-----------------------------------------------------------------------
| ID | Operation | NAME | ROWS | Bytes | COST (%CPU)| TIME |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 6 | 4564 (1)| 00:00:51 |
| 1 | SORT AGGREGATE | | 1 | 6 | | |
| 2 | INDEX FAST FULL SCAN| XBNIDENTS_PK | 6888K| 39M| 4564 (1)| 00:00:51 |
-----------------------------------------------------------------------
By simply break it down to 2 SELECT SQL, just 0.01 second
SELECT MIN(XBNIDENTSID) AS MIN
FROM ABELISTING.XBNIDENTS
UNION ALL
SELECT MAX(XBNIDENTSID) AS MAX
FROM ABELISTING.XBNIDENTS;
-----------------------------------------------------------------------
| ID | Operation | NAME | ROWS | Bytes | COST (%CPU)| TIME |
-----------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 2 | 12 | 6 (50)| 00:00:01 |
| 1 | UNION-ALL | | | | | |
| 2 | SORT AGGREGATE | | 1 | 6 | | |
| 3 | INDEX FULL SCAN (MIN/MAX)| XBNIDENTS_PK | 6888K| 39M| 3 (0)| 00:00:01 |
| 4 | SORT AGGREGATE | | 1 | 6 | | |
| 5 | INDEX FULL SCAN (MIN/MAX)| XBNIDENTS_PK | 6888K| 39M| 3 (0)| 00:00:01 |
-----------------------------------------------------------------------
Stability
RDBMS database and store procedure have been around for more than 20 years, and is proven stable. Building our core data process logic inside the database will be stable.
More components means more complexity, more coding and bugs, more maintenance job, and it’s not linear, it’s exponential.
All about database API's. The applications don't do table level(select/insert/update/delete) stuff, the apps don't even really *know* about tables.
On top of database schema we have an API that does the data stuff.
In the application we call this API but have our own application logic as well
(only application logic is in the application, data logic is -- well, right where it belongs -- next to the data, waiting for the 'next great programming paradigm to come along')
make software components modular
software modules must carry out a very specific task
(and be very efficient at carrying it out)
each software module should be loosely coupled (to limit dependencies)
It removes the need for triggers as all inserts, updates and deletes are wrapped in APIs. Instead of writing triggers you simply add the code into the API. I loath triggers.
It prevents people who don't understand SQL writing stupid queries.
All SQL would be written by PL/SQL developers or DBAs, reducing the likelyhood of dodgy queries.
The underlying structure of the database is hidden from the users, so I can make structural changes without client applications being changed.The API implementation can be altered and tuned without affecting the client application.
The same APIs are available to all applications that access the database. No duplication of effort.
Flexibility and Elegant programming
• PL/SQL is the most efficient language for data manipulation
– PL/SQL datatypes are SQL datatypes collection/array, nest object table … – no conversions
– Tight coupling between the language and the database (cursor for loops for example)
– We don’t need to open/close queries – manage lots of stuff
– We are somewhat protected from changes in the database
– You have sub-optimizations like cursor caching done for you.
(Native prefetch 100 rows, with FOR lc_cursor IN (select * from table_name) LOOP)
–
• Don’t forget the dependency mechanism you get!
Drop/add columns and select * from table_name,
Deploy at anytime after QA time, no build, no server restart, transparent when change table structure (physical database model)
• In PL/SQL it is very hard to not use bind variables correctly.
• In Java is it trivially easy to do it wrong – and it usually is.
• In PL/SQL – parse once, execute many is inherit in the environment.
• In Java, it must be coded – and it hardly ever is.
• In PL/SQL – “select *” can be safe (might not be the best approach, but is is “safe”)
• In Java – “select *” is deadly – but frequently used.
• PL/SQL can survive database schema changes such as a varchar2(80) -> varchar2(255) change
• Java cannot, you will have to inspect all code and change variable sizes.
• PL/SQL has that nice builtin dependency mechanism to avoid the “I didn’t know you used that” syndrome
• Java does not.
• … a long list goes from her…
• Embed SQL complexity into store procedure, give a simple interface to Jave developer
For example, book delete check:
Packaged Store PROCEDURE list_df(p_cursor IN OUT listidcurtyp, p_string VARCHAR2)
AS
i PLS_INTEGER;
BEGIN
OPEN p_cursor FOR
WITH sq
AS
(
SELECT SUBSTR(x, INSTR(x,',',1,LEVEL)+1, INSTR(x,',',1,LEVEL+1) - INSTR(x,',',1,LEVEL) -1) token
FROM (SELECT ','||l_str||',' x,l_str FROM (SELECT p_string l_str FROM dual))
CONNECT BY LEVEL <= LENGTH(l_str)-LENGTH(REPLACE(l_str,',',''))+1
)
SELECT A.listingsid listingsid
FROM abelisting.listings A, sq
WHERE A.listingsid = TO_NUMBER(sq.token)
AND A.rowdf = 'T';
Java side:
SELECT COLUMN_VALUE listingsid
FROM TABLE(abelisting.Sp_Sql_Query.list_df_tabf(:l_string));
Less code, simple is beautiful!
Beat me if you can write less Java code for below PL/SQL store procedure to reach same goal, just to compare the simplicity, not mention the performance yet:
1) For Loop
CREATE OR REPLACE
PROCEDURE process_data( p_inputs IN VARCHAR2 )
AS
BEGIN
FOR x IN ( SELECT * FROM EMP WHERE ename LIKE p_inputs )
LOOP
Process( X );
END LOOP;
END;
2) Enforce read/write consistency, update and delete in one transaction
PROCEDURE clear_pending_list_qty_forall
AS
TYPE listingsidList IS TABLE OF abelisting.list_qty_offset.listingsid%TYPE;
lt_listingsid listingsidList;
TYPE pendingList IS TABLE OF abelisting.list_qty_offset.pending%TYPE;
lt_pending pendingList;
l_cnt NUMBER;
BEGIN
DBMS_APPLICATION_INFO.SET_MODULE('ListLoad', 'Clear pending offset');
--To clear all the pending ordered books qty, into listigns
--Using RETURNING collection to store processing data, make sure you can always get an consistent image of listings.qty
--that is, never delete the extra rows, between update and delete.
-- Options 2 is DELETE with RETURNING list, then bulk FORALL UPDATE, 2 times faster
DELETE FROM abelisting.list_qty_offset
RETURNING listingsid, pending BULK COLLECT INTO lt_listingsid, lt_pending;
DEBUG.f('delete %s rows on abelisting.list_qty_offset', SQL%ROWCOUNT);
FORALL i IN lt_listingsid.FIRST .. lt_listingsid.LAST
UPDATE ABELISTING.listings SET quantity = quantity + lt_pending(i)
WHERE LISTINGSID = lt_listingsid(i);
l_cnt := SQL%ROWCOUNT;
DEBUG.f('updated qty on listing %s rows', l_cnt);
COMMIT;
/*
--Err logging
FOR i IN 1 .. lt_listingsid.COUNT
LOOP
DBMS_OUTPUT.PUT_LINE( 'updated listingsid = ' || lt_listingsid(i)||', qty = '||lt_pending(i) );
DEBUG.f( 'updated listingsid = ' || lt_listingsid(i)||', qty = '||lt_pending(i) );
END LOOP;
*/
EXCEPTION
WHEN OTHERS THEN
DEBUG.f( SUBSTR(TO_CHAR(SQLCODE)||': '||SQLERRM,1,100) );
RAISE;
END;
3) INSERT … SELECT from external_table (flat file), data loading from flat file
PROCEDURE isbn_recomd_full_load(p_add_rows IN OUT NUMBER)
IS
l_cnt NUMBER;
BEGIN
DBMS_APPLICATION_INFO.SET_MODULE('LB', 'isbn_recomd_full_load');
DEBUG.f('truncate table');
EXECUTE IMMEDIATE 'alter session set optimizer_mode=all_rows';
EXECUTE IMMEDIATE 'alter session set skip_unusable_indexes=true';
EXECUTE IMMEDIATE 'TRUNCATE TABLE librarything.isbnRecommendations';
DEBUG.f('unusable index');
--execute immediate 'alter index librarything.isbnRecommendations_isbn unusable';
DEBUG.f('INSERT +APPEND direct load');
INSERT /*+ APPEND */ INTO librarything.isbnRecommendations NOLOGGING
(isbn,recommendationSet)
SELECT isbn,recommendationSet
FROM librarything.isbnRecommendations_ext; -- the external table
l_cnt := SQL%RowCount;
DEBUG.f('INSERTed %s rows', l_cnt);
COMMIT;
p_add_rows := l_cnt;
DEBUG.f('rebuild index on isbn column');
---execute immediate 'alter index librarything.isbnRecommendations_isbn rebuild online';
DEBUG.f('rebuild index done');
DBMS_APPLICATION_INFO.SET_MODULE('LB', 'isbn_recomd_full_load done');
EXCEPTION
WHEN OTHERS THEN
DEBUG.f( SUBSTR(TO_CHAR(SQLCODE)||': '||SQLERRM,1,100) );
RAISE;
END;
My Utopian Development Environment
There is no SELECT/INSERT/UPDATE/DELETE/MERGE in Java code, the database access layer; only call a packaged database Store Procedure for a specific goal.
Communication
Efficiency is achieved by specializing and profession, classify into Java developer, database developer and backend developer. JAVA handle file processing and UI logic, database process logic is just inside the database, wrapped into database store procedure.
I know some backend developer can improve PL/SQL performance 8 times again by calling Pro*C or OCI*C code (Using SQL with array binds of 100 for Key Lookup and Insert), for the raw speed.
A general knowledge to know all other party doing is also necessary and important.
Data modeling
Design a sound data model is one of the most critical stages in the development of a computerized information system.
We’re pursuing a Complete, no Redundancy, Enforce business rule, Data Reusable, flexible and stable, Elegant data model, also for Communication, Integration and
Balance the Conflicting Objectives.
Please check attached email to see the problem could be easily solved by a fitted data model design; and how complex it is when you tackle this issue from Java world.
For database developer, data model is part of their life.
I) Binding Variable, naturally, implicitly.
II) do set process (100 rows array prefetch by default) to FOR LOOP.
III) debug.f : to Instrument the code
Compulsory PL/SQL APIs
Client application developers would have no direct access to tables. Not even for queries. All access would be provided by PL/SQL APIs (Include database Views).
I like this because:
- It removes the need for triggers as all inserts, updates and deletes are wrapped in APIs. Instead of writing triggers you simply add the code into the API. I loath triggers.
- It prevents people who don't understand SQL writing stupid queries.
All SQL would be written by PL/SQL developers or DBAs, reducing the likelyhood of dodgy queries. - The underlying structure of the database is hidden from the users, so I can make structural changes without client applications being changed.The API implementation can be altered and tuned without affecting the client application.
- The same APIs are available to all applications that access the database. No duplication of effort.
Our concept is "build the data API in the database, you call the data API".
Database API has been layered by different UI technologies over time.
All about API's. The applications don't do table level(select/insert/update/delete) stuff, the apps don't even really *know* about tables.
On top of database schema we have an API that does the data stuff.
In the application we call this API but have our own application logic as well
(only application logic is in the application, data logic is -- well, right where it belongs -- next to the data, waiting for the 'next great programming paradigm to come along')
- make software components modular
- software modules must carry out a very specific task
(and be very efficient at carrying it out) - each software module should be loosly coupled (to limit dependencies)
2009-01-05 Mon
2009-01-04 Sun
AnySQL.net
DBA notes
Oracle & Starcraft
eagle's home
Give you some color to see see!
AnySQL.net English
Oracle Scratchpad
Oracle Life
OracleDBA Blog---低调做人,高调做事!
Chanel [K]
xzh2000的博客
Oracle Security Blog
ERN空间
Eddie Awad's Blog
MySQL Performance Blog
The Tom Kyte Blog
Delicious/Fenng/oracle
AIXpert
O'Reilly Databases
Red Hat Magazine
DBASupport
DB2 Magazine 中文版
developerWorks 中国 : 技术文章 , 教程 AIX
Pythian Group Blog » Log Buffer
车东[Blog^2]
blue_prince
玉面飞龙的BLOG
此生 今世
人生就是如此
Orange Tiger 木匠 Creative and Flexible - go with flow
生活帮-LifeBang
Hey!! Sky!
dba on unix
Brotherxiao's Home
柔嘉维则@life.oracle.eng
Fenng's shared items in Google Reader
jametong's shared items in Google Reader
缥缈游侠-logzgh
Tanel Poder's blog: Core IT for geeks and pros
DBA Tools
ilonng
yangtingkun
NinGoo@Net
Oracle & Unix
Inside the Oracle Optimizer - Removing the black magic
Ricky's Blog on Testing and RAC
DBA@Taobao
存储部落
Simon Space
Alibaba DBA Team
Oracle Team @SNC
淘宝数据平台团队
OracleBlog.cn
中国雅虎_站长天下_www.dbaleading.com_原创文章
知道分子
支付志 - 支付宝官方 Blog
DBA notes
DBA日记
HttpWatch Blog
Fenng(DBAnotes) 的最新日记
木匠的天空 Oracle Architect and Developer