big bad join problems - Mailing list pgsql-general

From Dustin Sallings
Subject big bad join problems
Date
Msg-id Pine.SGI.3.95.990201111231.19615D-100000@bleu.west.spy.net
Whole thread Raw
List pgsql-general
    Two messages floated by here last week describing similar
optimizer problems, and I didn't see any responses to them.  One of them
was mine and it's causing some bad delays in my first attempt at running
Postgres in production at work.  The following query sits in the optimizer
(even just doing an explain) for an unreasonably long amount of time,
regardless of the amount of data in any of the tables:

    select events.event_id, events.hostdate, events.ts, events.priority,
        tags.tag_name, events.stack,
        messages.message,
        usernames.user_name as user_name,
        wwwusers.user_name as wwwuser,
        files.file_name as filename,
        scripts.file_name as scriptname,
        events.linenum
    from events, tags, messages, usernames, usernames as wwwusers,
        files, files as scripts
    where events.tag_id=tags.tag_id
        and events.message_id=messages.message_id
        and usernames.user_id = events.user_id
        and wwwusers.user_id = events.wwwuser_id
        and files.file_id = events.file_id
        and scripts.file_id = events.script_id

I sent a script to create the database (and this view) in my last message.
Does anyone have any idea what's causing this problem, or how to fix it?
I've done larger joins before...  Anyway, I'm going to have to denormalize
my database some to work around this.

--
SA, beyond.com           My girlfriend asked me which one I like better.
pub  1024/3CAE01D5 1994/11/03 Dustin Sallings <dustin@spy.net>
|    Key fingerprint =  87 02 57 08 02 D0 DA D6  C8 0F 3E 65 51 98 D8 BE
L_______________________ I hope the answer won't upset her. ____________


pgsql-general by date:

Previous
From: Daniele Orlandi
Date:
Subject: Variable as a variable name in PL/pgSQL
Next
From: Greg Youngblood
Date:
Subject: RE: [GENERAL] Importing to Postgres from Filemaker Pro