From: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
---|---|
To: | Gary Stainburn <gary(dot)stainburn(at)ringways(dot)co(dot)uk> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: multiple lookup per row |
Date: | 2001-07-20 15:58:45 |
Message-ID: | web-88758@davinci.ethosmedia.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Gary,
> I had the same problem the first time I went from writing sequential
> batch
> mainframe apps to event-driven interactive windows apps. Different
> mindset
> completely.
I grapple with the procedural <--> declarative switchover all the time.
In a way, procedural is easier, since set theory does not come
intuitively to any humans I know. In my biggest pgsql app there's quite
a number of things I did with LOOPs that could have been done with
properly structured queries.
> BTW, which would run fastest, or would there be much difference? (I
> would
> have thought not much as the plpgsql function still has to do the
> same select
> as your sub-selects are.)
Yes, but plpgsql does the selects one at a time, evaluates the response,
and proceeds on to the next. The declarative statement does them all in
batches, as the SQL engine is designed to do. Plus my way and Tom's way
can be built as views, allowing further optimization. Not to mention
that pure SQL will always be faster than even a trusted language.
In other words, my and Tom's queries should run about 50 times as fast
as the procedural method for large tables with indexes.
-Josh
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
From | Date | Subject | |
---|---|---|---|
Next Message | Jeff Eckermann | 2001-07-20 16:12:52 | RE: example of [outer] join |
Previous Message | Tom Lane | 2001-07-20 15:58:25 | Re: Cast '' (blank) to null date |