Couchbase Analytics is designed to handle ad hoc queries efficiently through parallel processing, but issues can arise when query modifications lead to performance drops, as demonstrated by a customer's experience. The underlying data consists of JSON documents detailing client charges, with fieldnames optimized for space efficiency and dates stored in epoch format. An initial query aimed at retrieving top revenue customer/service combinations within revenue code categories was complicated by a volume discount calculation, drastically increasing execution time. The slowdown was traced to the use of the "listify" function in the query execution plan, prompting a restructuring to compute sums outside a switch-case statement, which improved performance significantly. The article encourages users to report rare occurrences of the "listify" function in execution plans to Couchbase, as the optimizer continues to evolve, with improvements such as automatic rewriting of queries involving switch-case with aggregate functions planned for future releases. The piece concludes with resources for further learning about Couchbase's query language and acknowledges contributors to the discussion.