河南新华印刷集团有限公司32.ppt

上传人:e****s 文档编号:92251239 上传时间:2023-06-02 格式:PPT 页数:97 大小:306.50KB
返回 下载 相关 举报
河南新华印刷集团有限公司32.ppt_第1页
第1页 / 共97页
河南新华印刷集团有限公司32.ppt_第2页
第2页 / 共97页
点击查看更多>>
资源描述

《河南新华印刷集团有限公司32.ppt》由会员分享,可在线阅读,更多相关《河南新华印刷集团有限公司32.ppt(97页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、Advanced Perl DBIMaking simple things easyand difficult things possible by Tim Bunce2 2Advanced DBI tutorial Tim BunceJuly 2003Topical Topicsl Speed Speed Speed!l Handling handles and binding valuesl Error checking and error handlingl Wheels within wheelsl Transactionsl DBI for the webl Taintingl Ha

2、ndling LONG/BLOB datal Portabilityl Proxy power and flexible multiplexl Whats new and whats planned3 3Advanced DBI tutorial Tim BunceJuly 2003Trimmed Topics and Tipsl Lack of time prevents the inclusion of.n Details of issues relating to specific databases and drivers(other than where used as exampl

3、es of general issues)each driver would warrant a tutorial of its own!n Non-trivial worked examplesn Handy DBIx:*and other DBI related modulesn and anything Id not finished implementing when this was written.l But I hope youll agree that theres ample information in the following 90+slidesl Tips for t

4、hose attending the conference tutorial:n Doodle notes from my whitterings about the whys and wherefores on your printed copy of the slides as we go along.4 4Advanced DBI tutorial Tim BunceJuly 2003The DBI-Whats it all about?l The Perl DBI defines and implements an interface to databasesl Plug-in dri

5、ver modules do the database-specific workl DBI provides default methods,functions,tools etc for driversl Not limited to the lowest common denominatorl Designed and built for speedl Powerful automatic error checking built-inl Valuable detailed call tracing/debugging built-inl Useful detailed call pro

6、filing/benchmarking built-in5 5Advanced DBI tutorial Tim BunceJuly 2003DBI ModulePerl ApplicationDBD:Other DBD:Informix DBD:OracleOracle Server Informix Server Other ServerA picture is worth?Speed Speed Speed!What helps,what doesnt,and how to measure it7 7Advanced DBI tutorial Tim BunceJuly 2003Give

7、 me speed!l DBI was designed for speed from day onel DBI method dispatcher written in hand-crafted XS/Cl Dispatch to XS driver method calls is specially optimizedl Cached attributes returned directly by DBI dispatcherl DBI overhead is generally insignificant So well talk about other speed issues ins

8、tead.8 8Advanced DBI tutorial Tim BunceJuly 2003Partition for speedl Application partitioning do what where?-stop and think-work smarter not hardern Pick the right database for the job,if you have the choice.n Work close to the data Moving data to/from the client is always expensive Consider latency

9、 as well as bandwidth Use stored procedures where appropriate Do more in SQL where appropriate-get a good bookn Multiple simple queries with joins in Perl may be faster.n Use proprietary bulk-load,not Perl,where appropriate.n Mix n Match techniques as needed experiment and do your own benchmarks.9 9

10、Advanced DBI tutorial Tim BunceJuly 2003Prepare for speedl prepare()-what happens in the server.Receive and parse the SQL statement into internal form Get details for all the selected tables Check access rights for each Get details for all the selected fields Check data types in expressions Get deta

11、ils for the indices on all the fields in where/join clauses Develop an optimised query access plan for best execution Return a handle for all this cached informationn This can be an expensive process especially the access plan for a complex multi-table queryn Some databases,like MySQL,dont cache the

12、 information but have simpler,and thus faster,plan creation.10 10Advanced DBI tutorial Tim BunceJuly 2003How would you do it?l One possible approach:Select from one table using its key field(assume both tables have an index on key)Then,loop for each row returned,and.select from the other table using

13、 its key field and the current rows value fieldl But which table to select first?To keep it simple,assume that both tables have the same value in all rowsl If we know that t1.key=1 matches 1000 rows and t2.key=2 matches 1then we know that we should select from t2 firstbecause that way we only have t

14、o select from each table oncel If we selected from t1 firstthen wed have to select from t2 1000 times!l An alternative approach would be to select from both and merge.11 11Advanced DBI tutorial Tim BunceJuly 2003The best laid plansl Query optimisation is hard Intelligent high quality cost based quer

15、y optimisation is really hard!l Know your optimiser Oracle,Informix,Sybase,DB2,SQL Server etc.all slightly different.l Check what its doing Use tools to see the plans used for your queries-very helpfull Help it alongn Most big name databases have a mechanism to analyse and store the key distribution

16、s of indices to help the optimiser make good plans.Most important for tables with skewed(uneven)key distributions Beware:keep it fresh,old key distributions might be worse than nonen Some also allow you to embed hints into the SQL as comments Beware:take it easy,over hinting hinders dynamic optimisation.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 技术资料 > 工程图纸

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com