Efficient Pagination Using MySQL

Efficient Pagination Using MySQL

ID:33371781

大小:281.80 KB

页数:26页

时间:2019-02-25

Efficient Pagination Using MySQL_第1页
Efficient Pagination Using MySQL_第2页
Efficient Pagination Using MySQL_第3页
Efficient Pagination Using MySQL_第4页
Efficient Pagination Using MySQL_第5页
资源描述:

《Efficient Pagination Using MySQL》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库

1、EfficientPaginationUsingMySQLSuratSinghBhati(surat@yahoo-inc.com)RickJames(rjames@yahoo-inc.com)YahooIncPerconaPerformanceConference2009Outline1.Overview–CommonpaginationUIpattern–SampletableandtypicalsolutionusingOFFSET–TechniquestoavoidlargeOFFSET–Performancecomparison–Conce

2、rns-2-CommonPatterns-3-BasicsFirststeptowardhavingefficientpaginationoverlargedataset–Useindextofilterrows(resolveWHERE)–Usesameindextoreturnrowsinsortedorder(resolveORDER)Stepzero–http://dev.mysql.com/doc/refman/5.1/en/mysql-indexes.html–http://dev.mysql.com/doc/refman/5.1/en

3、/order-by-optimization.html–http://dev.mysql.com/doc/refman/5.1/en/limit-optimization.html-4-UsingIndexKEYa_b_c(a,b,c)ORDERmaygetresolvedusingIndex–ORDERBYa–ORDERBYa,b–ORDERBYa,b,c–ORDERBYaDESC,bDESC,cDESCWHEREandORDERbothresolvedusingindex:–WHEREa=constORDERBYb,c–WHEREa=const

4、ANDb=constORDERBYc–WHEREa=constORDERBYb,c–WHEREa=constANDb>constORDERBYb,cORDERwillnotgetresolveduisngindex(filesort)–ORDERBYaASC,bDESC,cDESC/*mixedsortdirection*/–WHEREg=constORDERBYb,c/*aprefixismissing*/–WHEREa=constORDERBYc/*bismissing*/–WHEREa=constORDERBYa,d/*disnotparto

5、findex*/-5-SampleSchemaCREATETABLE`message`(`id`int(11)NOTNULLAUTO_INCREMENT,`title`varchar(255)COLLATEutf8_unicode_ciNOTNULL,`user_id`int(11)NOTNULL,`content`textCOLLATEutf8_unicode_ciNOTNULL,`create_time`int(11)NOTNULL,`thumbs_up`int(11)NOTNULLDEFAULT'0',/*VoteCount*/PRIMARY

6、KEY(`id`),KEY`thumbs_up_key`(`thumbs_up`,`id`))ENGINE=InnoDBmysql>showtablestatuslike'message'GEngine:InnoDBVersion:10Row_format:CompactRows:50000040/*50Million*/Avg_row_length:565Data_length:28273803264/*26GB*/Index_length:789577728/*753MB*/Data_free:6291456Create_time:2009-

7、04-2013:30:45Twousecase:•Paginatebytime,recentmessageonepageone•Paginatebythumps_up,largestvalueonpageone-6-TypicalQuery1.GetthetotalrecordsSELECTcount(*)FROMmessage2.GetcurrentpageSELECT*FROMmessageORDERBYidDESCLIMIT0,20•http://domain.com/message?page=1•ORDERBYidDESCLIMIT0,20

8、•http://domain.com/message?page=2•ORDERBYidDESCLIMIT20,20•htt

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。