{"id":757,"date":"2020-01-08T20:26:21","date_gmt":"2020-01-08T20:26:21","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/performance\/microflow-retrieve-from-database-and-aggregate-should-be-together\/"},"modified":"2022-04-14T08:33:06","modified_gmt":"2022-04-14T08:33:06","slug":"retrieveaggregateadjacent","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/retrieveaggregateadjacent","title":{"rendered":"Microflow retrieve from database and aggregate should be adjacent"},"content":{"rendered":"\n<p style=\"text-align:center\">Introduced in version: 1.3 (29 Jan 2020)<\/p>\n\n\n\n<p>If a retrieve from the database and an aggregate are used they should be together, so Mendix can optimize the query to the database into 1 statement.<\/p>\n\n\n\n<p>A similar rule  <a href=\"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/retrieveaggregatenullified\">Retrieve &amp; aggregate combo should not be nullified by using the list<\/a> checks usage of the retrieve list in other places that would prevent the optimization from taking place.<\/p>\n\n\n\n<p><strong>Noncompliant example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"525\" height=\"218\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-57.png\" alt=\"\" class=\"wp-image-997\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-57.png 525w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-57-480x199.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 525px, 100vw\" \/><\/figure>\n\n\n\n<p><strong>Compliant example:<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"518\" height=\"207\" src=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-58.png\" alt=\"\" class=\"wp-image-998\" srcset=\"https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-58.png 518w, https:\/\/sdf-docs.clevr.com\/wp-content\/uploads\/2020\/01\/image-58-480x192.png 480w\" sizes=\"(min-width: 0px) and (max-width: 480px) 480px, (min-width: 481px) 518px, 100vw\" \/><\/figure>\n\n\n\n<p><em>Multiple aggregates after one retrieve are allowed at the moment, assuming they can all be optimized into 1 statement. This needs further investigation.<\/em><\/p>\n","protected":false},"featured_media":0,"parent":95,"menu_order":17,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-757","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/757"}],"collection":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=757"}],"version-history":[{"count":4,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/757\/revisions"}],"predecessor-version":[{"id":2457,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/757\/revisions\/2457"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/95"}],"next":[{"title":"Microflow should not apply entity access","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/microflowentityaccess","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/529"}],"prev":[{"title":"Many-to-many associations should have owner \"Default\"","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/associationownerboth","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1236"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=757"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}