From: Jackson, DeJuan <djackson@cpsgroup.com>
To: Howie <caffeine@toodarkpark.org>
To: Gene Selkov Jr. <selkovjr@mcs.anl.gov>
Cc: pierre <pierre@desertmoon.com>
Cc: pgsql-sql@postgreSQL.org
Subject: RE: [SQL] Joining bug????
Date: Tue, 27 Oct 1998 17:21:40 -0600
Message-ID: <F10BB1FAF801D111829B0060971D839F4ABB30@cpsmail> (raw)
> On Mon, 26 Oct 1998, Gene Selkov Jr. wrote:
>
> >
> > > I've been attempting to get my DB tuned to handle joins as best as
>
> > > possible. However, no matter which way I try to perform the joins,
> if I
> > > attempt to join more than two or three tables the joins becomes
> > > unbearably long not matter how many indexes I create in however
> many ways.
> >
> > Ditto. Never saw a quadruple join succeed, even with relatively
> small tables.
>
> Ive been playing with the idea of moving a client from MySQL to
> Postgres (
> views, triggers, and subselects would _really_ make my life easier ).
>
> ---[ CUT ]---
> SELECT
> account.accnum,
> account.accname,
> ((customers.firstname || ' ') || customers.lastname) as
> Customer,
> acctype.descr,
> account.balance,
> account.status,
> billdate.next
> FROM
> account,customers,acctype,billdate
> WHERE
> account.custnum=customers.custnum AND
> account.acctype=acctype.accid AND
> account.accnum=billdate.accnum AND
> account.accnum<20
> ORDER BY
> account.accnum
> ---[ CUT ]---
>
> works perfectly, takes about 2 seconds to complete. granted i have
> ( sometimes unique ) indexes on all the join columns.
>
> account has 7k rows, customers has 5k rows, acctype has 12 rows,
> billdate has 7k rows.
>
> a somewhat modified, real-world query ends up crashing postgres,
> though:
>
> ---[ CUT ]---
> select
> account.accnum,
> account.accname,
> account.totalfee,
> billdate.next,
> ((customers.firstname || ' ') || customers.lastname) as
> Customer,
> customers.company,
> customers.street,
> acctype.yearly
> FROM
> account,customers,acctype,billdate
> where
> account.totalfee>0.00 AND
> billtype=1 OR (billcc1stmo=1 AND
> account.created=billdate.last)
> AND
try: (billdate.billtype=1 OR (billdate.billcc1stmo=1 AND
account.created=billdate.last)) AND
> balance<>0.00 AND
> billdate.next>='1998-01-01' AND
> billdate.next<='1998-01-05' AND
> account.status<>'C' AND
> billdate.accnum=account.accnum AND
> account.custnum=customers.custnum AND
> account.acctype=acctype.accid
> ---[ CUT ]---
>
>
> > > My only solution was to create a hybrid table that contains the
> join of
> > > all of the tables I'm searching on with multi-keyed indexes. This
> is a
> > > VERY kludgy solution that makes changing the keys to my DB hard to
> change.
> >
> > The solution I use may be the worst imaginable kludge, but it works
> > great: I do the joins (as well as other set operations) on the
> client
> > side. Perl hashes are very good for that.
>
> try making a view. from what others have said, views save the query
> plan
> and have usually, at least for me, been _alot_ faster than normal
> queries.
>
> ---
> Howie <caffeine@toodarkpark.org> URL: http://www.toodarkpark.org
> "Oh my god, they killed init! YOU BASTARDS!"
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: djackson@cpsgroup.com, caffeine@toodarkpark.org, selkovjr@mcs.anl.gov, pierre@desertmoon.com
Subject: Re: [SQL] Joining bug????
In-Reply-To: <F10BB1FAF801D111829B0060971D839F4ABB30@cpsmail>
References: <F10BB1FAF801D111829B0060971D839F4ABB30@cpsmail>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox