As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.
Join the TIBCO Community TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.
From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
Request access to the private WebFOCUS User Group (login required) to network with fellow members.
Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.
It's been a long time since I took the FOCUS internals class. Is FOCUS "smart" enough to evaluate only once a DEFINEd field that is based on a constant? What if that constant is an amper variable? What if the constant is another DEFINEd field? Some examples:
I'll need to do some filtering using SUNDAY on millions of records.
... WHERE OTHER_DATE GT SUNDAY ...
Is it OK to define this field, or is it more efficient to create an amper variable outside of the TABLE request and use the amper variable in the WHERE statement (WHERE OTHER_DATE GT '&SUNDAY')?
In the internal matrix (or whatever they're calling it these days), FOCUS treats a defined field the same as a database field. It's just a column in the internal table. In other words, your field will exist in every row in the internal matrix. Even if it does evaluate it only once (and I don't think it does), you'll incur extra processing time due to extra I/O. An amper variable in your WHERE will be much more efficient.
The problem will be worse if you are accessing a relational database. If I am not mistaken (and I could be), using a defined field in a WHERE statement turns off the optimizer.
Posts: 135 | Location: Portland, OR | Registered: March 23, 2005
You're correct, define is on every record based on WITH also. Using define in WHERE will result in optimizer turn off if only selection is on the defined field. If you have other real fields it brings back as much as it can in the answer set before the defined selection. That is my understanding any way.
Not as efficient as on real fields, but sometimes the only way you can do what you want to do.
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004
Using a defined date field as part of your selection criteria for a relational database will fail optimization. Because part of the record selection fails, the RDBMS will also not be able to perform and sorting or aggregation. This can push a lot of the work back to FOCUS to handle and gets inefficient very quickly.
The good news is you can perform a lot of the same date functions used in DEFINEs within dialog manager commands. Because DM is evaluated before the SQL request is built, the where condition results in a test against a date constant -- which does translate. Here is some DM that should pull the same results as your defines:
Capture the Sunday date in an amper var... [qb] -SET &XTODAY=&YYMD; -SET &XDATE1=DATECVT(&XTODAY,'I8YYMD','YYMD'); -SET &XDATE2=DATEMOV(&XDATE1,'BOW'); -SET &XSUNDAY=DATECVT(&XDATE2,'YYMD','I8YYMD'); -SET &SUNDAY=EDIT(&XSUNDAY,'9999-99-99'); -? &X [/qb] [qb] CURRENTLY DEFINED & VARIABLES STARTING WITH 'X': &XDATE1 = 38202 &XDATE2 = 38199 &XSUNDAY = 20050801 &XTODAY = 20050804 > > [/qb] ...and use the &var in your test: [qb] WHERE OTHER_DATE GE '&SUNDAY';[/qb] TABLE will see a comparison to a date constant: [qb] WHERE OTHER_DATE GE '2005-08-01';[/qb] and, assuming OTHER_DATE is a real field, will pass the condition through to the rdms.
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005
One more thing. Be careful when using DATEMOV and the BOW option. BOW is always a Monday, and if the input date is a Saturday or Sunday, it is the next Monday! Therefore, if "today" is a Saturday, BOW puts you into next week! There is another topic on this subject that was begun July 1 2005. I don't like the solution at the end (DOWK and offsets seems cleaner to me) but I guess it works.