Database 板


LINE

※ 引述《jameswiki》之銘言: : <前面吃光光了..太長了XD> : Well,蠻多人討論的..呵, : 用guid,newid()來產生值做為PK的目的很多, : 其實這種用Guid來做PK鍵的討論很多, 是否合用,見人見智, : flack大大,您資料表上千萬上億筆的,或許不合用, : 不過換成小弟,但在初始規劃時,我大概不會規劃這種一次存上億筆的, : 不用比那個小小的字串跟整數當PK的效能, : 光是left join一次上億筆就吃不消了 : 可能我經驗不足,不過若100萬筆資料來做連幾次left join, : 前台的client大概都不要用了,上億筆?..我不敢想... 的確沒辦法用Left Join,一定要Inner Join 而且要參考我之前講的一個關鍵:Table裡面不能有半個字串欄位,只能有整數或Datetime (Datetime只有八位元) : (不要跟我說所有欄位都在同一table,你從來不用left join,那又要討論資料庫規劃 : -->離題了XD) 沒錯,面對這麼大的資料量作垂直或水平分割(Partition)是基本手段 不過還是有些場合時常要跨Partition查詢時,SQL 2000以前的Partition View 就常常不能將效能最佳化,而且它能Union的資料表還有255個的上限,所以這些 可能就得將資料塞回去同一個資料表 所幸SQL 2005的Partition Table終於比較強一點,而可支援的Partition數目 也比較多,但這也使資料表規劃技巧更形重要 : 我引述下面網址的文章 : http://blog.miniasp.com/post/2008/01/08/The-Gospel-of-the-GUID.aspx : 其實我自己用久了,發現其實好處不止如此了..不一一列舉,就以這份文章討論吧 感謝您提供資料參考,這裡也提供一份SQL Magazine的資料 http://www.sqlmag.com/Articles/ArticleID/23449/23449.html?Ad=1 Surrogate Key vs. Natural Key 不過它是付費文章,只能請各位自己想辦法,節錄以下幾個重點,基本上就是看資料數 如果資料行數多到不可能同時塞進記憶體,那最好讓欄位寬度與Index瘦身,來盡可能 塞入更多Index到記憶體中 The kind of database platform you work from can help determine whether you need to use a natural value or a surrogate identifier for your primary key. The criterion that a primary key must be minimal means the fewer the columns, the better. A single-column primary key simplifies data storage, retrieval, and coding. SQL Server automatically creates a unique index (and, by default, a clustered index) on any column designated as a primary key. In Figure 1's Purchase table example, if the primary key were CustID plus PurchaseDate, SQL Server would create a 12-byte index key. If you created a surrogate key with an integer data type for the Purchase table's primary key, the index key would be one-third the size. Eight bytes here and 8 bytes there don't sound like much until you start calculating the additional I/O required for reading and writing hundreds of thousands of records. If the records are short, you ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can fit more records on a page that's being read into memory or written to disk. Here's a general rule: The more records that can fit on a page, the better the performance. ........ When people ask me which makes a better primary key—a natural value or a surrogate identifier—I answer that the choice depends on the situation. In all the modeling work that I've done, I've rarely been able to identify a suitable natural key as a candidate for the job. I've been able to identify natural search keys, both unique and nonunique. But when I apply the prerequisite tests—is it unique? does it apply to all rows? is it minimal? is it stable over time?—to these natural keys, most natural keys fail. My personal preference is to use a surrogate key unless I can identify an appropriate natural key that meets the four criteria for the primary key. --



※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.70.51.189
1F:推 jameswiki:soga,所以,像您這種資料庫有上億筆,無法用left join 03/19 11:27







like.gif 您可能會有興趣的文章
icon.png[問題/行為] 貓晚上進房間會不會有憋尿問題
icon.pngRe: [閒聊] 選了錯誤的女孩成為魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一張
icon.png[心得] EMS高領長版毛衣.墨小樓MC1002
icon.png[分享] 丹龍隔熱紙GE55+33+22
icon.png[問題] 清洗洗衣機
icon.png[尋物] 窗台下的空間
icon.png[閒聊] 双極の女神1 木魔爵
icon.png[售車] 新竹 1997 march 1297cc 白色 四門
icon.png[討論] 能從照片感受到攝影者心情嗎
icon.png[狂賀] 賀賀賀賀 賀!島村卯月!總選舉NO.1
icon.png[難過] 羨慕白皮膚的女生
icon.png閱讀文章
icon.png[黑特]
icon.png[問題] SBK S1安裝於安全帽位置
icon.png[分享] 舊woo100絕版開箱!!
icon.pngRe: [無言] 關於小包衛生紙
icon.png[開箱] E5-2683V3 RX480Strix 快睿C1 簡單測試
icon.png[心得] 蒼の海賊龍 地獄 執行者16PT
icon.png[售車] 1999年Virage iO 1.8EXi
icon.png[心得] 挑戰33 LV10 獅子座pt solo
icon.png[閒聊] 手把手教你不被桶之新手主購教學
icon.png[分享] Civic Type R 量產版官方照無預警流出
icon.png[售車] Golf 4 2.0 銀色 自排
icon.png[出售] Graco提籃汽座(有底座)2000元誠可議
icon.png[問題] 請問補牙材質掉了還能再補嗎?(台中半年內
icon.png[問題] 44th 單曲 生寫竟然都給重複的啊啊!
icon.png[心得] 華南紅卡/icash 核卡
icon.png[問題] 拔牙矯正這樣正常嗎
icon.png[贈送] 老莫高業 初業 102年版
icon.png[情報] 三大行動支付 本季掀戰火
icon.png[寶寶] 博客來Amos水蠟筆5/1特價五折
icon.pngRe: [心得] 新鮮人一些面試分享
icon.png[心得] 蒼の海賊龍 地獄 麒麟25PT
icon.pngRe: [閒聊] (君の名は。雷慎入) 君名二創漫畫翻譯
icon.pngRe: [閒聊] OGN中場影片:失蹤人口局 (英文字幕)
icon.png[問題] 台灣大哥大4G訊號差
icon.png[出售] [全國]全新千尋侘草LED燈, 水草

請輸入看板名稱,例如:BabyMother站內搜尋

TOP