Query Problem

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Query Problem
Дата
Msg-id 39F78FE7.DA915769@agliodbs.com
обсуждение исходный текст
Ответы Re: Query Problem  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: Query Problem  (Tom Lane <tgl@sss.pgh.pa.us>)
HELP! ... pg_locale ???  (Sandis Jerics <sandis@mediaparks.lv>)
Список pgsql-sql
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_CWHERE 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
informationtechnology      josh@agliodbs.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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Jie Liang
Дата:
Сообщение: Re: Problem whith Stored queries
Следующее
От: Hosokawa Tetsuichi
Дата:
Сообщение: Re: Surprising sequence scan when function call used