I'm doing some reporting-type work with PG, with the vast
majority of queries hitting upwards of 25% of the table, so
being executed as seq scans.

It's a fairly large set of data, so each pass is taking quite
a while, IO limited. And I'm looking at doing dozens of
passes.

It would be really nice to be able to do all the work with a
single pass over the table, executing all the queries in
parallel in that pass. They're pretty simple queries, mostly,
just some aggregates and a simple where clause.

There are some fairly obvious ways to merge multiple
queries to do that at a SQL level - converting each query
into a function and passing each row from a select * to
each of the functions would be one of the less ugly.

Or I could fire off all the queries simultaneously and hope
they stay in close-enough lockstep through a single pass
through the table to be able to share most of the IO.

Is there a commonly used trick to doing this that I should
know about?

Cheers,
  Steve




---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

              http://www.postgresql.org/docs/faq

Reply via email to