--- title: "Auditing for the Presence of OR/NOT Logic in Queries and Rules" slug: "auditing-for-the-presence-of-or-not-logic-in-queries-and-rules" status: "new" updated: 2026-07-21T20:42:46Z published: 2026-07-21T20:42:46Z canonical: "knowledge.technolutions.net/auditing-for-the-presence-of-or-not-logic-in-queries-and-rules" stale: true --- > ## Documentation Index > Fetch the complete documentation index at: https://knowledge.technolutions.net/llms.txt > Use this file to discover all available pages before exploring further. # Auditing for the Presence of OR/NOT Logic in Queries and Rules Use helper queries to identify queries and rules that may contain expensive logic, such as `OR`, `NOT`, or `NOT IN`. These results can help prioritize review when auditing query and rule performance. > [!WARNING] > 📝 Note > > The helper queries identify items for review. A result does not automatically mean that the query or rule is incorrect, only that the logic may deserve closer inspection. #### Try a Slate example 💼 Copy this [Suitcase](https://knowledge.technolutions.net/docs/en/suitcase) ID and paste it in **Database → Suitcase Import** to import the helper queries: ```SuitcaseID 0fe2d369-3341-4e17-952d-6775ce31aae4:slate-examples ``` > [!TIP] > ⭐ Get Inspired > > This article was adapted from [a post by Technolutions staff](https://community.technolutions.net/get-inspired/post/helper-queries---querying-on-or-not-in-queries-or-rules-5cAg76GE7jYaZS0) in the Slate Community Forums' Get Inspired space. Have a great idea for a Get Inspired post? [Let us know](https://community.technolutions.net/get-inspired/new?post_type=gnHx7As1gZ8r6Ld)! ## Included helper queries ### Rules Using OR or NOT Operators This query uses the Configurable Joins **Rule** base and Custom SQL to identify rules that contain `OR` or `NOT` operators. Use the results to find rules that may benefit from a logic review or a more efficient structure. ### Query Efficiency Auditor This query uses Custom SQL to identify queries that include logic such as `OR`, `NOT`, or `NOT IN`. It can also identify queries based on larger tables, such as Message, Ping, or Source, where inefficient logic may have a larger performance impact. ## Review the results 1. Run the helper query. 2. Open each returned query or rule. 3. Review the filter logic, base, joins, and exports. 4. Look for opportunities to replace negative logic with positive logic, split large queries into smaller queries, or narrow the population earlier in the query. 5. Test any revised query or rule before replacing the original configuration. > [!TIP] > ⭐ Best practice > > Use these queries as part of a periodic performance review, especially before major cycle milestones when rules, portals, and recurring exports receive heavier use.