There and Back Again As Quick As a Flash Stefan Winkler Independent Software Developer and IT Consultant CDO Committer stefan@winklerweb.net @xpomul on Twitter
CDO in a nutshell
CDO in a nutshell
CDO in a nutshell CDOID attribute reference
CDO in a nutshell CDOID CDOID attribute reference CDOID
CDO in a nutshell CDOID CDOID attribute reference
CDO in a nutshell CDOID CDOID attribute reference
CDO in a nutshell CDOID attribute reference
CDO in a nutshell CDOID CDOID attribute reference
CDO in a nutshell CDOID CDOID attribute reference
CDO in a nutshell CDOID attribute reference CDOID attribute reference
CDO in a nutshell CDOID attribute reference CDOID attribute reference
Layers App Logic EMF Model CDO CDO IStore Code
App Logic EMF Model CDO CDO IStore Code
Choose the Right! time to read 10,000 objects (msec) time to write 10,000 objects (msec) MEM DB (h2 in-proc) 1.121 1.287 283 766 DB (h2 net) DB (MySQL) 4.269 9.381 5.546 6.686 Hibernate (MySQL) 22.314 10.151 MongoDB (net) 519.063 1.503 DB4O (in-proc) 1.701 0 200.000 400.000 600.000 2.268 0 2.500 5.000 7.500 10.000
Choose the Right! Store Usage Scenarios Pros Cons MEMStore DBStore HibernateStore MongoDB Store DB4OStore ObjectivityStore prototyping, testing common/default solution custom DB schema required No SQL DB wanted, fast writing speeds required supports all CDO features supports all CDO features custom DB schema and mapping fast writing speeds not persistent DB selection and tuning adds to complexity only supports subset of CDO features, slower slow reading speeds, limited commit size No SQL DB wanted, fast reading speeds required fast reading speeds slower writing speeds dual licence OODB with commercial support needed performance not measured commercial licence, performance not measured
Choose the Right Database! time to read 10,000 objects time to write 10,000 objects (msec) h2 (net) 4.269 5.546 MySQL (net) 9.381 6.686 PostgreSQL (net) 4.231 6.606 0 2.500 5.000 7.500 10.000 5.000 5.833 6.667 7.500
Choose the Right Database! time to read 10,000 objects time to write 10,000 objects (msec) h2 (net) 4.269... and tweak it! 5.546 Standard Configurations!!! MySQL (net) 9.381 6.686 PostgreSQL (net) 4.231 6.606 0 2.500 5.000 7.500 10.000 5.000 5.833 6.667 7.500
App Logic EMF Model CDO CDO IStore Code
Choose the Right Repository Mode Audit Mode v1 v2 v3 v4 v5 v6 v7 Time
Choose the Right Repository Mode Non-Audit Mode v1 v2 v3 v4 v5 v6 v7 Time
Choose the Right Repository Mode Branching Mode 0:v1 v2 v3 v4 v5 v6 1:v1 1:v2 2:v1 2:v2 2:v3 Time
Choose the Right DBStore Mapping! non-audit repo mode writes deltas Order date sum no historic ( audit ) views Product Product date Product date sum number sum price Order id version date sum 1 2 3/29/12 102.34 Product id version number price 2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51 Order_Product_List id version index value 1 2 0 2 1 2 1 3 1 2 2 4
Choose the Right DBStore Mapping! Order audit repo mode classic always writes complete list range-based writes deltas id version date sum 1 2 3/29/12 102.34 Order_Product_List Product id version number price 2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51 id version index value 1 2 0 2 1 2 1 3 1 2 2 4
Choose the Right DBStore Mapping! Order audit repo mode classic always writes complete list id version date sum 1 2 3/29/12 102.34 Product id version number price 2 2 1-423-4 39.12 3 2 1-485-3 60.71 4 2 1-584-2 2.51 range-based writes deltas Order_Product_List id from to index value 1 1 null 0 2 1 1 1 1 4 1 2 null 1 3 1 1 1 2 3 1 2 null 2 4
Choose the Right DBStore Mapping! branching repo mode classic vs. range-based copy-lazy (default) vs. copy-on-branch Order_Product_List id branch from to index value 1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 1 1 2 null 2 4
Choose the Right DBStore Mapping! branching repo mode classic vs. range-based copy-lazy (default) vs. copy-on-branch Order_Product_List id branch from to index value 1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 1 1 2 null 2 4 Order_Product_List id branch from to index value 1 2 1 null 1 5
Choose the Right DBStore Mapping! branching repo mode classic vs. range-based copy-lazy (default) vs. copy-on-branch Order_Product_List id branch from to index value 1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 1 1 2 null 2 4 Order_Product_List id branch from to index value 1 2 1 null 1 5
Choose the Right DBStore Mapping! branching repo mode classic vs. range-based copy-lazy (default) vs. copy-on-branch Order_Product_List id branch from to index value 1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 1 1 2 null 2 4
Choose the Right DBStore Mapping! branching repo mode classic vs. range-based copy-lazy (default) vs. copy-on-branch Order_Product_List id branch from to index value 1 1 1 null 0 2 1 1 1 1 1 4 1 1 2 null 1 3 1 1 1 1 2 3 1 1 2 null 2 4 Order_Product_List id branch from to index value 1 2 1 null 0 2 1 2 1 null 1 5 1 2 1 null 2 4
Choose the Right DBStore Mapping! 9.000 6.750 time to insert 100 objects at beginning time to insert 100 objects in the middle time to insert 100 objects at the end 8.941 4.500 4.581 2.250 0 1.442 1.483 1.481 1.506 1.473 1.491 681 736 688 721 non-audit audit branching branching w/ ranges
App Logic EMF Model CDO CDO IStore Code
Choose the Right Transport Layer! CDO CDO Computer 1 Computer 2 TCP (true client/server) CDO CDO TCP (same computer) CDO CDO JVM (same JVM)
A Word On Caching Revision Caches in CDO use Soft references Caches grow until memory limit is reached CDO CDO View Cache can be configured to use strong or weak references instead View Cache (Soft Ref) Session Cache (Soft Ref) Repository Cache (Soft Ref) view.options().setcachereferencetype(referencetype.strong);
App Logic EMF Model CDO CDO IStore Code
Choose the Right Model Configuration! time to read 100,000 objects time to write 100,000 objects (msec) Native 8.581 2.802 Reflective 8.882 3.076 Legacy 11.302 4.460 0 3.000 6.000 9.000 12.000 0 2.500 5.000 7.500
App Logic EMF Model CDO CDO IStore Code
Make Use of CDO Loading Policies! Lazy Collection Loading session.options().setcollectionloadingpolicy( CDOUtil.createCollectionLoadingPolicy( /* initial = */ 5, /* onresolve = */ 5)); Explicit Prefetching CDOObject fromcdo = getmyobjectfromcdo(); fromcdo.cdoprefetch(/* depth = */ 3); Prefetching by Policy view.options().setrevisionprefetchingpolicy( CDOUtil.createRevisionPrefetchingPolicy( /* size = */ 5));
Leftovers Things I did not talk about unordered collections store queries (use with caution!) LOBs & streaming
Summary Choose the Right! Choose the Right Database! Choose the Right Repository Mode! Choose the Right DBStore Mapping! Choose the Right Transport Layer! Choose the Right Model Configuration! Make Use of CDO Loading Policies!