Tag: sql
I want a real work!!
by calendarw on Sep.30, 2009, under diary
今日十分唔開心, 成日都做唔到野. 一個由古人完全用 Smart UI 黎寫既系統, 今日大爆獲. 而最重要既係, 那個經過七至八人經手過既系統, 最後一個識跟既人都係上個月離開了, 這個系統由上個月中開始由我同另一個同事跟. 那個系統除了用左 Smart UI 之外, 最重要既係用左好多即時既 Temp Table, 個人覺得無必要, 而佢用既用法係 Create 左個 Temp Table, Insert 一堆 Record, 之後係果個 Table 度為 Record 再做不同既 Edit (e.g. Delete 唔啱既野), 呢種寫法除左令程式不能在同一個 IDE 度編寫, 檢查之外, 對 database server 既 loading 都十分大, 唯一既好處係只要在 Stored Procedure 入面加 Insert 或者加 Delete Statement, 就可以好容易出到想要既野之外, 我覺得無乜用, 而且仲令維護性極度減低, 呢個係我今日心情極唔開心既原因.
今次爆獲既原因係 database server loading 問題, 除了用 Temp Table 之外, Where Case 入面有著以下一些浪 over-loading 既 statement:
select a, b, c from tblA where d + cast(varchar(1), e) in (select d + cast(varchar(1), e) from tblA where f = 'Y') -- 1. d + e != unique, and cannot determined by pkey -- 2. select count(pkey) from tblA > 700k+
除了這樣既 statement 而且滿怖整個系統外, 仲有好多 runtime calculation, 搞到幾個有必要成日行既 Stored Procedure 行一次要成三秒至廿秒以上. 部機已經係 4GB Ram 加上 4 個 CPU 了, 32-bit 既機能跟本上已經用盡, Ram 已經長期係 3.7 GB usage 既狀態, 而 Connection 亦有成千幾個. 除了 rebuild index (平時 schedule weekly rebuild), review where case 之外, 我已經諗唔到有咩辦法, 所有可以既 index 既地方都已經加左, 除左寫呢套系統既人已經走晒外, 因為聽日放假, 星期五公司大部份人又放假 (唔係香港), 所以呢殺那咩都唔改得, 亦唔敢改, 個系統已經進入了一個做又死, 唔做又死既局面.
因為呢 d case, 我 develop 緊既 project 都因為呢個關係 Pending 左, 但 User 又迫住話要 UAT, 個 Support Case 多到做都做唔晒, 時間上跟本咩都做唔到, 生產力極低, 想改又改唔到, 而我星期五就孤身隻影地在 Client Site 度面對前人積下來既爛攤子, 心情極為煩燥.
除左呢 d 之外, 系統係由唔同時期 Project 既 Scope 不段增加而成的, 但因為一路以來既轉變, 好多資訊又無正規地做得好, 系統又無 Version Control, 無 Change Management, 無 Requirement Management, 無 Software Design, 無 Design Review, 無 Test Case, 只有一路以來跟著 User Comment 而改既差劣製成品, 因為系統已經係 Production 關係, 好多野已經不能容易地改, 好多問題其實出自當初既 System Design 上, 而因為有另一個唔知幾時會上既 Project 話會 Replace 左呢個劣品, 但同時做 Design 既人都只係參考舊既 Design, 而不問問題所在地做著一個只有無這個系統經驗而又參照舊系統既 Designer 意見做出來既 Schema, 令到好多野想改都改唔到, 苦不堪言.
因為呢堆爛攤子, 而隨著一大堆 Support Case, 生產力減慢, 加上變左長期係 Site, 咩成積都做唔到出黎, 自自然然老細唔會睇好你, 升職? 無, 加人工? 無, 工作時間不段加長, 日日只有被人埋怨這裏做得唔好, 那裏做得唔好…
為什麼, 我只想找個正正經經做軟件設計既工作環境都咁難, 讀軟件出身既我, 為何一日都黑都只係對著一些由無經驗既舊人做出黎既無設計製成品, 而不能好好地做好自己有軟件設計, 軟件架構既 Project 呢.
I want a real work. To improve my experience and my skill.
Error 29506 when installing SQL Server 2005 Management Studio Express on Windows 7
by calendarw on Aug.25, 2009, under error handling
- Click “All Programs”, select “Accessories”, right click the Command Prompt shortcut and select “Run as Administrator”.
- Click “Yes” to accept the warning
- Use command “cd” to navigate to the installation directory.
- Type the installation file to execute file. (e.g. SQLServer2005_SSMSEE_x64.msi) and complete the installation.
Rebuild Index on MsSQL
by calendarw on Apr.28, 2009, under database
今日要對現有既 Table 做 Performance Testing, 但因為要 join 太多既 Table, 搜尋一個要 join 4 個 Table 先拎到想要既 “一隻” Record 既時間竟然要 11 秒, 可想而知個 Table Size 有幾大吧 (其實七位數字既 Record Count 啫, 而 where case 只有兩個用 ‘=’ 既 criteria, 而且所有 Record 只能 insert, 不能 delete).
經過我 rebuild 過接近 10 個已有既 index 之後 (等了好幾分鐘), 搜尋時間減少至只需 5 秒…
以下係 mssql 2005 下 rebuild index 既一個 statement 既例子
ALTER INDEX IX_tblMaster ON tblMaster REBUILD;
IX_tblMaster 係 index 名
tblMaster 係 table 名
Update Statement with Other Table
by calendarw on Apr.23, 2009, under coding snippet
呢排為設置 Testing 場而預備緊 d SQL statement, 有部份 Data 得 detail table, 但使用時要整返個 master 比佢, 所以就要使用 update statement 黎 link 返唔同 table 既 key, 以下係一個例子:
update tblModel set series_pkey = tblSeries.pkey from tblModel, tblSeries where tblSeries.full_name = 'A Series' and tblModel.full_name like 'A %';
Today finding
by calendarw on Aug.07, 2008, under daily finding
MS SQL Server 2008 Released
唔知香港人用得到佢幾多成既功能呢….
7 Ways to Improve Your Software Release Management
不過無咁上下規模都唔會跟
- Understand the current state of release management.
- Establish a regular release cycle.
- Get lightweight processes in place. Test them early and review them regularly.
- Establish a release infrastructure early.
- Automate and standardize as much as you can.
- Establish positive expectations.
- Invest in people.

