How would you profile and optimize a slow-running SQL query or data transformation job impacting a core reporting dashboard? For the coding portion, implement the transformation that aggregates numeric values by key while preserving each key's first-seen order. Input is a list of [key, value] pairs, and output is a list of [key, total] pairs. For example, [['A', 2], ['B', 3], ['A', 4]] produces [['A', 6], ['B', 3]]. Keys are non-empty strings and values are integers.
def aggregate_dashboard_rows(records):