× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



This stuff is fun :-)

Exactly. I thought, but wasn't sure, that current_date is a reserved
special value in SQL. But if not, it would have to be a correlated subquery.

The original is essentially a join and could be rearranged by the optimizer
to be handled as a join. It could be written directly as

select item_master.* from item_master
join vndmst on vendor = vnd
where crt_date = current_date

Right?

As far as what the old optimizer does, I've heard of TPC-H queries that
takes days on the 400 and and hours on AIX DB2, similar hardware on both
boxes. The new engine is trying to bring the 400 much more in line. These
queries are complex multiple join monstrosities.

At 12:31 PM 3/15/02 -0500, you wrote:
> >From: Vernon Hamberg [mailto:vhamberg@attbi.com]
> >I believe (may be wrong) that this subselect is run repeatedly...
> >Select * from item_master
> >where vendor in (select vnd
> >                         from vndmst
> >                         where crt_date = current_date)
>
>You're 1/2 right and 1/2 wrong. Correlated subqueries are rerun for each
>row, but they have to be. A correlated subquery is one where the records
>selected in the subquery depend on a value in the row being evaluated in the
>main query. However, non-correlated sub queries should only be run once for
>the entire statement. If this is not the case it's a bug in the SQL
>optimizer and should be reported to IBM. In the case above the 'in'
>predicate select will only be evaluated once since the results don't depend
>on any values in the main select. Had the select been
>
>Select * from item_master
>where vendor in (select vnd
>                          from vnditm
>                          where vnditm.itm = item_master.itm)
>
>Where the idea was to select all the rows in item_master where the vendor on
>the item was listed as a vendor that sold that item in the vnditm file then
>that subselect would be reevaluated each time. (Granted this would be a
>stupid way to get this result set)
>
>-Walden
>
>------------
>Walden H Leverich III
>President
>Tech Software
>(516) 627-3800 x11
>(208) 692-3308 eFax
>WaldenL@TechSoftInc.com
>http://www.TechSoftInc.com
>
>_______________________________________________
>This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
>To post a message email: MIDRANGE-L@midrange.com
>To subscribe, unsubscribe, or change list options,
>visit: http://lists.midrange.com/cgi-bin/listinfo/midrange-l
>or email: MIDRANGE-L-request@midrange.com
>Before posting, please take a moment to review the archives
>at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.