The paper presents optimal aggregation algorithms for middleware systems that handle databases with multiple attributes, each having a grade for an object. The goal is to find the top k objects based on a monotone aggregation function, such as min or average. The naive algorithm accesses every object to compute its grade, but it is inefficient. Fagin's Algorithm (FA) is more efficient, but it is not optimal for all aggregation functions. The Threshold Algorithm (TA) is introduced as a more optimal solution. TA is instance optimal, meaning it performs well for all databases and aggregation functions, and it requires a small, constant-size buffer, unlike FA, which needs larger buffers. TA allows early stopping, providing an approximate version of the top k answers. The paper also considers different access modes: sorted access (sequential) and random access. TA is optimal in both scenarios, even when random access is expensive. The paper shows that TA is instance optimal for all monotone aggregation functions, and it can be modified to handle approximate answers. It also discusses scenarios where random access is not possible or expensive, and presents algorithms like NRA (No Random Access) and CA (Combined Algorithm) that are instance optimal in those cases. The paper concludes that TA is the most efficient algorithm for finding the top k answers in databases with multiple attributes.The paper presents optimal aggregation algorithms for middleware systems that handle databases with multiple attributes, each having a grade for an object. The goal is to find the top k objects based on a monotone aggregation function, such as min or average. The naive algorithm accesses every object to compute its grade, but it is inefficient. Fagin's Algorithm (FA) is more efficient, but it is not optimal for all aggregation functions. The Threshold Algorithm (TA) is introduced as a more optimal solution. TA is instance optimal, meaning it performs well for all databases and aggregation functions, and it requires a small, constant-size buffer, unlike FA, which needs larger buffers. TA allows early stopping, providing an approximate version of the top k answers. The paper also considers different access modes: sorted access (sequential) and random access. TA is optimal in both scenarios, even when random access is expensive. The paper shows that TA is instance optimal for all monotone aggregation functions, and it can be modified to handle approximate answers. It also discusses scenarios where random access is not possible or expensive, and presents algorithms like NRA (No Random Access) and CA (Combined Algorithm) that are instance optimal in those cases. The paper concludes that TA is the most efficient algorithm for finding the top k answers in databases with multiple attributes.