Re: Fastest way to join materalized view to child tables

From: Jim Nasby <decibel(at)decibel(dot)org>
To: Postgres User <postgres(dot)developer(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Fastest way to join materalized view to child tables
Date: 2007-07-13 15:39:29
Message-ID: C25371BE-FC6E-44D4-BB19-703A66D9F594@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Jul 9, 2007, at 10:07 PM, Postgres User wrote:
> materialized view - view_a
> child tables - table_a, table_b, table_c
>
> Here's my question- what's the fastest what to retrieve rows from each
> of the child tables after I get results from view_a ?
> I don't like using temp tables in Postgres (too much pain in the
> past), so first selecting into a temp table which could subsequently
> be joined against the child tables isn't appealing to me.
>
> The result set from materialized view_a will never exceed 60 rows, so
> I'm thinking about this:
> a) LOOP on a SELECT FROM view_a
> b) for each record, add the row id to one of 3 comma delimited strings
> (one per child table)
> c) perform a SELECT WHERE IN (delimited_string) from each child table

Build an array of IDs and then use that in your 3 queries with the
ANY operator.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jim Nasby 2007-07-13 15:41:19 Re: how to resolve invalid primary checkpoint
Previous Message Jim Nasby 2007-07-13 15:35:09 Re: Strange Problem