{"id":1531,"date":"2014-04-18T09:02:25","date_gmt":"2014-04-18T08:02:25","guid":{"rendered":"http:\/\/soci.hu\/blog\/?p=1531"},"modified":"2014-04-18T09:02:25","modified_gmt":"2014-04-18T08:02:25","slug":"az-orm-batching-perf-vonzata","status":"publish","type":"post","link":"https:\/\/soci.hu\/blog\/index.php\/2014\/04\/18\/az-orm-batching-perf-vonzata\/","title":{"rendered":"Az ORM batching perf vonzata"},"content":{"rendered":"<p>Az egyik \u00fcgyfelemn\u00e9l let\u00f6ltenek p\u00e1r sz\u00e1z sort mem\u00f3ri\u00e1ba Entity Frameworkkel. Ott C# k\u00f3ddal mindenf\u00e9le komplex m\u00f3don kital\u00e1lj\u00e1k, melyik entit\u00e1st hogyan kell m\u00f3dos\u00edtani, majd a m\u00f3dos\u00edt\u00e1sok eredm\u00e9ny\u00e9t az EF betolja adatb\u00e1zisba. B\u00e1r a szerveren nem volt nagy terhel\u00e9s, m\u00e9gis volt amikor 1000 f\u00f6l\u00f6tt volt a batch request\/second.<\/p>\n<p>Mi\u00e9rt? Mert az EF nem tudja \u00f6sszenyal\u00e1bolni a m\u00f3dos\u00edt\u00e1sokat, hanem egyes\u00e9vel k\u00fcldi be \u0151ket. Azaz, ha 300 sor m\u00f3dosult, akkor 300 update fog bemenni, ennyi roundtrip lesz. Ez annyira g\u00e1z, hogy egyszer\u0171en nem \u00e9rtem az MS-t, mi\u00e9rt nincs m\u00e9g batching a 6-os EF-ben.<\/p>\n<p>Mutatok egy p\u00e9ld\u00e1t, mekkora hat\u00e1sa van ennek. Az NHibernate b\u00e1rmennyire is elhanyagolt manaps\u00e1g, de \u0151 sz\u00e9pen tud batchelni.<br \/>\nA k\u00f6vetkez\u0151 p\u00e9ld\u00e1ban let\u00f6lt\u00f6k 20000 sort, m\u00f3dos\u00edtom mindet, majd visszamentem a m\u00f3dos\u00edt\u00e1sokkal. EF-fel ez 11mp.<br \/>\nNHibernate-tel meg tudom mondani, h\u00e1ny utas\u00edt\u00e1st k\u00fcldj\u00f6n be egyszerre. Ett\u0151l f\u00fcgg\u0151en az al\u00e1bbi sz\u00e1mok j\u00f6nnek ki:<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nNHib test - BatchSize: 1000000, Duration: 00:00:00.9390957\r\nNHib test - BatchSize: 100000, Duration: 00:00:00.8363326\r\nNHib test - BatchSize: 10000, Duration: 00:00:00.8463299\r\nNHib test - BatchSize: 1000, Duration: 00:00:01.0654756\r\nNHib test - BatchSize: 100, Duration: 00:00:01.3361271\r\nNHib test - BatchSize: 10, Duration: 00:00:02.4312424\r\nNHib test - BatchSize: 1, Duration: 00:00:10.4669159\r\n<\/pre>\n<p>El\u00e9g nagy batch m\u00e9retn\u00e9l a 10 mp lemegy 1mp al\u00e1!<br \/>\nEF-n\u00e9l 11, \u00e9s k\u00e9sz. C\u00e1foljon meg valaki, hogy rosszul tudom, \u00e9s az EF is tudja ezt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Az egyik \u00fcgyfelemn\u00e9l let\u00f6ltenek p\u00e1r sz\u00e1z sort mem\u00f3ri\u00e1ba Entity Frameworkkel. Ott C# k\u00f3ddal mindenf\u00e9le komplex m\u00f3don kital\u00e1lj\u00e1k, melyik entit\u00e1st hogyan kell m\u00f3dos\u00edtani,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,25,6,74,88,4,30],"tags":[],"class_list":["post-1531","post","type-post","status-publish","format-standard","hentry","category-net","category-adonet","category-adatbazisok","category-entity-framework","category-nhibernate-adonet","category-szakmai-elet","category-sql-server"],"_links":{"self":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1531"}],"version-history":[{"count":2,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531\/revisions"}],"predecessor-version":[{"id":1533,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1531\/revisions\/1533"}],"wp:attachment":[{"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1531"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1531"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/soci.hu\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1531"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}