What problem does it solve? Salesforce queries on large objects time out, throw QUERY_TIMEOUT or OPERATION_TOO_LARGE errors, and fail batch start methods when filters are not selective. This Skill provides the optimizer thresholds, measurement tools, and rewrite patterns needed to make SOQL and SOSL queries index-driven and fast. ## Core Features & Use Cases - Selectivity Diagnosis: Measure filter selectivity with GROUP BY ROLLUP counts, the REST Query Plan explain endpoint, and SOQL_EXECUTE_EXPLAIN debug logs, then compare against documented standard and custom index thresholds. - Query Rewriting: Fix anti-patterns such as negative operators, null filters, leading wildcards, formula-field filters, OFFSET paging past 2,000 rows, and aggregate queries assigned directly to lists. - Safe Dynamic SOQL: Build injection-safe dynamic queries with Database.queryWithBinds, allowlisted identifiers, and String.escapeSingleQuotes, plus user-mode security enforcement with WITH USER_MODE. - Use Case: A batch job's start method fails with QUERY_TIMEOUT on a 5-million-row Account object. Use this Skill to measure the filter's cardinality, confirm relativeCost above 1.0 via the explain endpoint, request a custom index or rewrite the WHERE clause, and verify the new plan is index-driven. ## Quick Start Ask the assistant to diagnose why a specific SOQL query is timing out and rewrite it to be selective using the sf-soql-sosl-optimization skill.