Re: Problem with query - Mailing list pgsql-general

From Michael Nolan
Subject Re: Problem with query
Date
Msg-id CAOzAquKTanKKONL0NXO=0SneQfG7W+tspcJHJTA7KUtmbNC-Aw@mail.gmail.com
Whole thread Raw
In response to Re: Problem with query  (Chris Curvey <chris@chriscurvey.com>)
List pgsql-general
On 4/11/14, Chris Curvey <chris@chriscurvey.com> wrote:
> On Fri, Apr 11, 2014 at 1:50 PM, Susan Cassidy <
> susan.cassidy@decisionsciencescorp.com> wrote:
>
>> I have a query with several joins, where I am searching for specific data
>> in certain columns.

Have you tried running each of your joins separately to see if there
are row values common to both tables, ie:

select count(*) from scenes s
left outer join scene_thing_instances si on s.scene_id =
si.scene_id

then

select count(*) from scene_thing_instances si
left outer join scene_things st on si.scene_thing_id =
st.scene_thing_id

etc.

I find when building complex queries (I've written some that ran over
100 lines and involved a dozen or more joined tables), I need to build
them up, testing them as I build.
--
Mike Nolan


pgsql-general by date:

Previous
From: Chris Curvey
Date:
Subject: Re: Problem with query
Next
From: Moshe Jacobson
Date:
Subject: Re: Database Design: Maintain Audit Trail of Changes