Re: Query Problem

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: sqllist <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Query Problem
Date: 2000-10-26 15:22:15
Message-ID: Pine.BSF.4.10.10010260821280.26411-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


What is the explain output for the queries you've tried?

Stephan Szabo
sszabo(at)bigpanda(dot)com

On Wed, 25 Oct 2000, Josh Berkus wrote:

>
> Folks:
>
> Here's the problem, in abstract: I need to select every record in table
> A that does not have a link in table B Join Table C where Table
> C.account = 11
>
> The relevant fields:
>
> Table_A
> CaseID
> Data
>
> Table_B
> GroupID
> CaseID
> Amount
>
> Table_C
> GroupID
> AccountID
>
> Thus, I need to select:
>
> SELECT Data FROM Table A
> WHERE CaseID NOT IN (
> SELECT CaseID FROM Table_B, Table_C
> WHERE Table_B.GroupID = TableC.GroupID
> AND TableC.AccountID = 11)
>
> The problem is, since Table_B and Table_C are large (10,000 records +)
> this exclusion query takes several *minutes* to run.
>
> I've fooled around with drectional joins, views, and temporary tables,
> but I can seem to find anything that works faster. Suggestions?
>
> -Josh Berkus
>
> --
> ______AGLIO DATABASE SOLUTIONS___________________________
> Josh Berkus
> Complete information technology josh(at)agliodbs(dot)com
> and data management solutions (415) 436-9166
> for law firms, small businesses fax 436-0137
> and non-profit organizations. pager 338-4078
> San Francisco
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ulf Mehlig 2000-10-26 15:24:27 "average" time
Previous Message Tom Lane 2000-10-26 15:21:44 Re: Alternate Database Locations