🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.vdbase.data.sql
Article #46

Re: SQL OUTER JOIN giving unpredictable results

#46
From: Mark Berry
Date: Tue, 23 Feb 1999 00:00
33 lines
1864 bytes
Romain,

Romain Strieff [TeamB] wrote:
> No idea, are there _simple_ indexes for the involved fields?

No, but there are indexes that _begin_ with the involved field.  Adding
a simple index didn't affect performance.

I believe your earlier example could be simplified to omit the condition
within the subquery:

  DELETE FROM MASTER M WHERE NOT M.ORDER_ID IN;
      (SELECT ORDER_ID FROM CHILD C)

But even with that simplification, executing a SELECT with the "NOT IN
(subquery)" approach takes 1 minute 39 seconds on a medium-size table,
compared to 7 seconds for the "OUTER JOIN" approach.  And "delete for
not seek(key,alias)" takes 4 seconds.

I can only guess that the IN operator is not very efficient; maybe it
was tested more on short lists of values.  Too bad, as it does seem to
be the most elegant solution.

So I guess it's OUTER JOIN to get a rowset for displaying the records,
and "delete for not seek()" to do the actual deletion.  So much for
OODML.

Thanks again for your input.  I'm frustrated by the difficulties of
performing this simple operation, but I'm grateful for the SQL lesson!

Regards,

Mark Berry
Technical Details
Message-ID: <36D34BF6.997CBB03@nospam.mcbsys.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <36CE28AB.704C343B@nospam.mcbsys.com> <MPG.1138ae8f9e4467a8989e73@forums.inprise.com> <36D1B713.8E3E747B@nospam.mcbsys.com> <MPG.113ca18edb8d372f989ea1@forums.inprise.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: ff5a1,3dc8d9196f7bc07d
X-Google-Attributes: gidff5a1,public
From: Mark Berry <markb@nospam.mcbsys.com>
Subject: Re: SQL OUTER JOIN giving unpredictable results
Date: 1999/02/23
Message-ID: <36D34BF6.997CBB03@nospam.mcbsys.com>
X-Deja-AN: 447702244
Content-Transfer-Encoding: 7bit
References: <36CE28AB.704C343B@nospam.mcbsys.com> <MPG.1138ae8f9e4467a8989e73@forums.inprise.com> <36D1B713.8E3E747B@nospam.mcbsys.com> <MPG.113ca18edb8d372f989ea1@forums.inprise.com>
Content-Type: text/plain; charset=us-ascii
Organization: MCB Systems
Mime-Version: 1.0
Reply-To: markb@nospam.mcbsys.com
Newsgroups: borland.public.vdbase.data.sql