{"id":235,"date":"2019-11-01T13:44:03","date_gmt":"2019-11-01T13:44:03","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/performance\/not-expressions-in-an-x-path-retrieve\/"},"modified":"2020-07-08T14:35:30","modified_gmt":"2020-07-08T14:35:30","slug":"negativepositivexpath","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/negativepositivexpath","title":{"rendered":"Positive conditions should be preferred when retrieving data"},"content":{"rendered":"\n<p>Using a negative condition (e.g.  <code>not <\/code>and <code>!=<\/code>) in a database retrieve is slower than using a positive one. This is because negative queries do not let the database to use indices since it is not possible to index what is not there. <\/p>\n\n\n\n<p>Where possible formulate logic in a positive way. <\/p>\n\n\n\n<p><strong>Noncompliant example:<\/strong><br><code>[EnumAttribute != Module.Enumeration.C]<\/code><\/p>\n\n\n\n<p><strong>Compliant example:<\/strong><\/p>\n\n\n\n<p><code>[EnumAttribute = Module.Enumeration.A or EnumAttribute= Module.Enumeration.B] <\/code><\/p>\n","protected":false},"featured_media":0,"parent":95,"menu_order":23,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-235","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/235"}],"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=235"}],"version-history":[{"count":5,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/235\/revisions"}],"predecessor-version":[{"id":1012,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/235\/revisions\/1012"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/95"}],"next":[{"title":"Retrieve & aggregate combo should not be nullified by using the list","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/retrieveaggregatenullified","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/758"}],"prev":[{"title":"Only short actions should be used in a loop","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/performance\/loopheavyaction","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1147"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=235"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}