🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #163

Re: HAVING or WHERE

#163
From: Bill Todd [TeamB]
Date: Tue, 24 Jun 2008 17:18
24 lines
1922 bytes
Hs wrote:

> What is happening? Generaly what is the difference in resuls and in
> background between calling HAVING or WHERE for non aggregation fields?

In case one the optimizer elected to read farmer in natural order and
use the primary index of buy to locate the record in buy that matched
the current record in farmer. This means that every record in buy was
located in the index then read from disk before the WHERE conditions
could be applied.

In case two the optimizer elected to sort farmer, sort buy then merge
the two streams. Although you cannot tell from the plan the WHERE and
HAVING conditions were probably applied to buy as it was read in
natural order so only the matching records had to be sorted and merged.
This resulted in much less I/O than locating all of the buy records one
at a time through the index.

Why did the optimizer elect to use the index in one case and do a sort
merge in the other? Only one (or possibly two) people know and they are
in InterBase R&D.:)

-- 
Bill Todd (TeamB)
Technical Details
Message-ID: <48612c58$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <48611ee3$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,8b9906a31c39f622
X-Google-Attributes: gid114a0e,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Bill Todd [TeamB]" <no@no.com>
Subject: Re: HAVING or WHERE
Newsgroups: borland.public.interbase.sql
References:  <48611ee3$1@newsgroups.borland.com>
Organization: The Database Group, Inc.
User-Agent: XanaNews/1.18.1.9
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
NNTP-Posting-Host: 63.147.41.232
Message-ID: <48612c58$1@newsgroups.borland.com>
Date: 24 Jun 2008 10:18:16 -0700
X-Trace: newsgroups.borland.com 1214327896 63.147.41.232 (24 Jun 2008 10:18:16 -0700)
Lines: 24
X-Authenticated-User: btodd
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!feeder.erje.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail