MySQL:主键的大小对性能的影响

| No Comments | No TrackBacks
http://mysqldba.blogspot.com/2008/04/mysql-uc-2007-presentation-file.html 的PPT:
Record every Referral for Flickr Realtime

可以看到大师强烈推荐使用整型ID作为主键和索引。
从实际应用的情况中,之前曾有过一次使用28byte的字符串做主键的例子,只有200w数据的时候,竟然比一个700w数据的有更多列但使用整形主键的表慢很多,特别是进行批量操作时,很多时候更是有SQL执行超过1分钟,导致系统抖动非常厉害。


Start over
• Converted the URL into a 64-bit ID
• CONV(SUBSTR(MD5(Url),0,16),16,10)
• ==
• 64-bit number
• For added protection its unique for the
owner
• Reduced Primary key size to 8 bytes +
owner, object, object-type


INNODB & Strings
• Indexing a string takes a lot of space
• Indexing a large string takes even more
space
Each index has its own 16KB page.
• Fragmentation across pages was hurting
the app - chewing up I/O
• That's a lot of disk space chewed up per
day


INNODB & High Concurrency of
String Writes
• Requirement: 300 ms for total db access
FOR ALL Apps
• Writes when the datafile(s) are greater
then the buffer_size slow down at high
concurrency
• 10 ms to 20 seconds sometimes for the
full transaction
• Noticed replication keeping up

--EOF--

No TrackBacks

TrackBack URL: http://www.guduo.net/cgi-bin/mt/mt-tb.cgi/74

Leave a comment

Pages

May 2016

Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        

About this Entry

This page contains a single entry by 谷多 published on April 23, 2008 11:31 AM.

DreamHost 瘫痪了!!! was the previous entry in this blog.

InnoDB Performance Optimization 性能优化学习1 is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.