{"record":{"id":"9059198ba3523303","repo":"apache/cassandra","slug":"cannot-have-more-than-secondary-indexes-per-table","errorCode":null,"errorMessage":"Cannot have more than 'secondary_indexes_per_table_fail_threshold' included/excluded indexes, found ","messagePattern":"Cannot have more than 'secondary_indexes_per_table_fail_threshold' included/excluded indexes, found ","errorType":"validation","errorClass":"InvalidRequestException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/db/filter/IndexHints.java","lineNumber":379,"sourceCode":"     * {@link InvalidRequestException} will be thrown.\n     * </p>\n     * All the mentioned indexes should exist in the index registry of the queried table,\n     * or an {@link InvalidRequestException} will be thrown.\n     *\n     * @param included the names of the indexes to include when executing the query\n     * @param excluded the names of the indexes to exclude when executing the query\n     * @param table the queried table\n     * @param indexRegistry the index registry of the queried table\n     * @return the index hints represented by the specified sets of CQL names\n     * @throws InvalidRequestException if any of the specified indexes do not exist in the specified index registry\n     */\n    public static IndexHints fromCQLNames(Set<QualifiedName> included,\n                                          Set<QualifiedName> excluded,\n                                          TableMetadata table,\n                                          IndexRegistry indexRegistry)\n    {\n        if (included != null && included.size() > maxIncludedOrExcludedIndexCount())\n            throw new InvalidRequestException(TOO_MANY_INDEXES_ERROR + included.size());\n\n        if (excluded != null && excluded.size() > maxIncludedOrExcludedIndexCount())\n            throw new InvalidRequestException(TOO_MANY_INDEXES_ERROR + excluded.size());\n\n        IndexHints hints = IndexHints.create(fetchIndexes(included, table, indexRegistry),\n                                             fetchIndexes(excluded, table, indexRegistry));\n\n        if (hints == IndexHints.NONE)\n            return hints;\n\n        // Ensure that no index is both included and excluded\n        Set<IndexMetadata> conflictingIndexes = Sets.intersection(hints.included, hints.excluded);\n        if (!conflictingIndexes.isEmpty())\n        {\n            throw new InvalidRequestException(CONFLICTING_INDEXES_ERROR + IndexMetadata.joinNames(conflictingIndexes));\n        }\n\n        // Ensure that all nodes in the cluster are in a version that supports index hints, including this one","sourceCodeStart":361,"sourceCodeEnd":397,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/db/filter/IndexHints.java#L361-L397","documentation":"InvalidRequestException from IndexHints.fromCQLNames when the set of included index names exceeds the secondary_indexes_per_table_fail_threshold limit. Cassandra caps how many index hints may be attached to a query to bound planning cost.","triggerScenarios":"A CQL SELECT with an INCLUDED INDEXES list longer than the configured fail threshold, resolved in fromCQLNames before indexes are fetched.","commonSituations":"Auto-generated queries hinting dozens of indexes, misconfigured or too-low threshold in cassandra.yaml, bulk tooling copying hints across queries.","solutions":["Reduce the number of included indexes in the query to the essential ones","Raise the secondary_indexes_per_table_fail_threshold setting if the workload genuinely needs more","Drop redundant indexes and hints entirely"],"exampleFix":"// before\nSELECT * FROM t WHERE ... ; -- INCLUDE INDEXES (i1, i2, ..., i20)\n// after\nSELECT * FROM t WHERE ... ; -- INCLUDE INDEXES (i1) -- only the index actually needed","handlingStrategy":"validation","validationCode":"if (includedIndexes.size() > maxThreshold) throw new IllegalArgumentException(\"Too many included indexes: \" + includedIndexes.size());","typeGuard":null,"tryCatchPattern":"try { session.execute(stmt); } catch (InvalidRequestException e) { if (e.getMessage().contains(\"secondary_indexes_per_table_fail_threshold\")) reduceHintsAndRetry(); }","preventionTips":["Keep hint lists small — only indexes the planner actually needs","Check the configured fail threshold before generating bulk hints","Avoid auto-hinting every index on the table"],"tags":["cassandra","index-hints","limits","cql"],"backgroundTag":"invalid-query-parameter","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}