Here is a question about SQL. I have a one-to-many pair of tables (call them P and
C for parent and child). For each row of P, there are many rows in C with data, and I
want to sort P on the min(c.data). The basic query is simple:
select p_id, min(data) as m from c group by p_id order by
I have a query that needs to run faster, with the obvious solution being to add an index.
But to confirm this, I ran explain analyze. When I run the actual query, it
consistently takes 6-7 seconds by the wall clock. My application with a
verbose mode enabled reports 6.6 seconds