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灯, 水草

请输入看板名称,例如:e-shopping站内搜寻

TOP