Couchbase Server 6.5 introduces significant enhancements to the handling of IN lists in N1QL queries, optimizing runtime performance by employing hash tables for large IN lists and dynamic index span generation for query parameters. When an IN list exceeds 16 elements, it is converted into a hash table, making evaluations more efficient compared to sequential element comparisons. The optimizations require the IN list to be static, or composed of constants and query parameters, while dynamic index span generation improves index scan efficiency by creating precise spans at runtime, provided the IN list size is known. Uncorrelated subqueries in IN clauses can be manually rewritten using common table expressions (CTEs) to leverage these optimizations, enhancing query performance by dynamically generating index spans during execution. These advancements collectively enhance the efficiency of IN list handling, making queries faster and more resource-effective.