{"id":38490,"date":"2022-01-27T11:21:24","date_gmt":"2022-01-27T11:21:24","guid":{"rendered":"https:\/\/arquiconsult.com\/?p=38490"},"modified":"2024-10-23T11:00:21","modified_gmt":"2024-10-23T10:00:21","slug":"improve-performance-with-partial-records","status":"publish","type":"post","link":"https:\/\/arquiconsult.com\/en\/improve-performance-with-partial-records\/","title":{"rendered":"#012 IMPROVE PERFORMANCE WITH PARTIAL RECORDS"},"content":{"rendered":"<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px; text-align: justify;\">\n<p>Since the release of Business Central 2020 wave 2, we got a new capability called Partial Records. It consists in the possibility to specify the fields that should be loaded from a Record or RecordRef.<\/p>\n<p>Without the use of Partial Records, Business Central would load all data from the record even if you only needed to access one or two fields.<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div><strong>\u00a0<\/strong><\/div>\n<div style=\"text-align: left;\"><strong>SetLoadFields<\/strong><\/div>\n<p style=\"text-align: left;\">Specifies a set of fields to be initially loaded when the record is retrieved from its data source. A call to this method will overwrite any fields that were previously set to load.<\/p>\n<p style=\"font-weight: 400; text-align: left;\"><strong>Example of code:<\/strong><\/p>\n<p style=\"text-align: left;\"><img loading=\"lazy\" class=\"size-medium wp-image-37793 aligncenter\" src=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/01\/SetLoadFields-640x226.png\" alt=\"SetLoadFields\" width=\"640\" height=\"226\" srcset=\"https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/01\/SetLoadFields-640x226.png 640w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/01\/SetLoadFields-768x272.png 768w, https:\/\/arquiconsult.com\/wp-content\/uploads\/2022\/01\/SetLoadFields.png 862w\" sizes=\"(max-width: 640px) 100vw, 640px\" title=\"-\"><\/p>\n<p style=\"font-weight: 400; text-align: left;\"><strong>AddLoadFields<\/strong><\/p>\n<p style=\"text-align: left;\">Similar function to SetLoadFields that has one big difference: if the function is called multiple times, the new call does not reset fields that were already set (even if they were set using SetLoadFields).<\/p>\n<p style=\"font-weight: 400; text-align: left;\"><strong>Important notice<\/strong><\/p>\n<p style=\"text-align: left;\">If the AL Code accesses a field that has not been selected for loading, the platform will perform an implicit GET, loading all the fields from the Record.<\/p>\n<p style=\"text-align: left;\"><strong>The benefits<\/strong><\/p>\n<ul style=\"font-weight: 400; text-align: left;\">\n<li>Microsoft states that it\u2019s particularly beneficial when table extensions are used. Each table extension is a separate table in SQL and when the data from a table is loaded, SQL will join the table and the extensions using the primary key.<\/li>\n<li>This feature is especially advantageous in reading-based scenarios as it\u2019s not recommended to use partial records on a record that will do inserts, deletes, or copies to temporary records.<\/li>\n<li>Also in Microsoft docs:\u00a0<em>&lt;&lt;Testing on the previous example code showed that the execution time for loading only the &#8220;Standard Cost&#8221; field was\u00a0<strong>nine times faster<\/strong> than loading all normal fields.&gt;&gt;<\/em><\/li>\n<\/ul>\n<p style=\"font-weight: 400; text-align: left;\"><strong>Recently added on BC19<\/strong><\/p>\n<ul style=\"font-weight: 400;\">\n<li style=\"text-align: left;\">Partial Records on List Pages &#8211; the server will read only those fields shown in the TableRelation lookup page from the database.<\/li>\n<li style=\"text-align: left;\">Partial Records on TableRelation Lookup Pages &#8211; the server will read only those fields that are shown in the list page from the database.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<div class=\"services_vertical horizontal_services row\" style=\"background-color: #f7f7f7; padding: 25px; border-radius: 5px;\"><strong>Official documentation from Microsoft is available here:<br \/>\n<\/strong><strong> <a href=\"https:\/\/docs.microsoft.com\/en-us\/dynamics365\/business-central\/dev-itpro\/developer\/devenv-partial-records\" target=\"_blank\" rel=\"noopener\">https:\/\/docs.microsoft.com\/en-us\/dynamics365\/business-central\/dev-itpro\/developer\/devenv-partial-records<\/a><\/strong><\/div>\n<p>&nbsp;<\/p>\n<!--themify_builder_content-->\n<div id=\"themify_builder_content-38490\" data-postid=\"38490\" class=\"themify_builder_content themify_builder_content-38490 themify_builder tf_clear\">\n    \t<!-- module_row -->\n\t<div  data-lazy=\"1\" class=\"module_row themify_builder_row tb_nus1581 tb_first tf_clearfix\">\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_cai8581 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module text -->\n<div  class=\"module module-text tb_9tkr581 arquitps-data  \" data-lazy=\"1\">\n        <div  class=\"tb_text_wrap\">\n    <p><script>\njQuery(\".tbp_post_month:contains(Janeiro)\").html(\"January\");\n\njQuery(\".tbp_post_month:contains(Fevereiro)\").html(\"February\");\n\n\njQuery(\".tbp_post_month:contains(Mar\u00e7o)\").html(\"March\");\n\n\njQuery(\".tbp_post_month:contains(Abril)\").html(\"April\");\n\n\njQuery(\".tbp_post_month:contains(Maio)\").html(\"May\");\n\n\njQuery(\".tbp_post_month:contains(Junho)\").html(\"June\");\n\n\njQuery(\".tbp_post_month:contains(Julho)\").html(\"July\");\n\njQuery(\".tbp_post_month:contains(Agosto)\").html(\"August\");\n\njQuery(\".tbp_post_month:contains(Setembro)\").html(\"September\");\n\njQuery(\".tbp_post_month:contains(Outubro)\").html(\"October\");\n\njQuery(\".tbp_post_month:contains(Novembro)\").html(\"November\");\n\njQuery(\".tbp_post_month:contains(Dezembro)\").html(\"December\");\t\n\n\n\n<\/script><\/p>    <\/div>\n<\/div>\n<!-- \/module text -->\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t\t<!-- module_row -->\n\t<div  data-anchor=\"sucesso\" data-hide-anchor=\"1\" data-lazy=\"1\" class=\"module_row themify_builder_row sucesso repeat tb_has_section tb_section-sucesso tb_nvy7196 tf_clearfix\" >\n\t    \t\t<div class=\"row_inner col_align_top col-count-1 tf_box tf_w tf_rel\">\n\t\t\t<div  data-lazy=\"1\" class=\"module_column tb-column col-full first tb_sshy196 tf_box\">\n\t\t\t    \t        <div class=\"tb-column-inner tf_box tf_w\">\n\t\t    <!-- module buttons -->\n<div  class=\"module module-buttons tb_i14k197 buttons-horizontal transparent popmake-24705 large circle tf_textc\" data-lazy=\"1\">\n    \t<div class=\"module-buttons-item tf_inline_b\">\n\t\t\t\t\t\t\t<a href=\"#\" class=\"ui builder_button tb_default_color\" >\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"tf_inline_b tf_vmiddle\">Give as a Feedback and Suggest Questions<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<\/a>\n\t\t\t    \t<\/div>\n\t<\/div>\n<!-- \/module buttons -->\n\t        <\/div>\n\t    \t<\/div>\n\t\t    <\/div>\n\t    <!-- \/row_inner -->\n\t<\/div>\n\t<!-- \/module_row -->\n\t<\/div>\n<!--\/themify_builder_content-->\n","protected":false},"excerpt":{"rendered":"<p>Since the release of Business Central 2020 wave 2, we got a new capability called Partial Records. It consists in the possibility to specify the fields that should be loaded from a Record or RecordRef. Without the use of Partial Records, Business Central would load all data from the record even if you only needed [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":37984,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2099],"tags":[2076],"acf":[],"_links":{"self":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/38490"}],"collection":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/comments?post=38490"}],"version-history":[{"count":0,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/posts\/38490\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media\/37984"}],"wp:attachment":[{"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/media?parent=38490"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/categories?post=38490"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/arquiconsult.com\/en\/wp-json\/wp\/v2\/tags?post=38490"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}