Topics: |
Adapter optimization allows the RDBMS to perform the work for which it is best suited, reducing the volume of RDBMS-to-server communication and improving response time. It also enables the RDBMS to exploit its own internal optimization techniques.
For more information, see Optimizing Requests and Optimizing Requests to Pass Virtual Fields Defined as Constants.
How to: |
Reference: |
The SET OPTNOAGGR command provides finely-tuned control of adapter behavior for optimization. Users who for any reason wish to prevent passing aggregation to the RDBMS can use this command. An example of such a reason might be where NULL values occur in aggregated data with calculations. The SET OPTNOAGGR command causes the adapter to generate SQL without passing aggregation to the DBMS. Aggregation is instead performed internally by the server while JOIN and SORT operations are handled by the RDBMS.
If any DEFINE field contains calculations with NULL fields, then such operations cannot be translated to SQL and passed to DBMS because they always return NULL. It has to be processed by FOCUS.
This can be achieved by SET OPTIMIZATION OFF.
However, in some cases it is preferable to use the off-load JOIN and SORT operation to DBMS for better performance while leaving AGGREGATION to FOCUS.
SQL SQLADW SET OPT {AGGR|NOAGGR}
where:
Directs the adapter to off-load aggregated DEFINE fields to the DBMS. This is the default setting.
Directs the adapter to generate SQL without passing aggregation to the DBMS. Aggregation is, instead, performed internally by the server, while JOIN and SORT operations are handled by the RDBMS. This setting can also be used to provide backwards compatibility for applications that were written based on the functionality of the previous release, when less SQL was off-loaded to the RDBMS. For example, when a calculation on aggregated fields may have contained NULL data that was not processed by the RDBMS NVL( ) function.
SQL SQLADW SET OPTIFTHENELSE ON DEFINE FILE EMPINFO DEF3 = IF FIRST_NAME EQ 'RITA' THEN 1 ELSE 0; END TABLE FILE EMPINFO PRINT FIRST_NAME IF DEF3 EQ 2 END
Because DEF3 EQ 2 will never be true, the adapter passes the WHERE test 1=0 (which is always false) to the RDBMS, returning zero records from the RDBMS:
SELECT T1."FN" FROM USER1."EMPINFO" T1 WHERE (1 = 0) FOR FETCH ONLY;
Since the FOCUS reporting language is more extensive than native SQL, the data adapter cannot pass certain DEFINE expressions to the RDBMS for processing. The data adapter does not offload DEFINE-based aggregation and record selection if the DEFINE includes:
X=X+1;
Note: Do not confuse the FOCUS user-written subroutines MAX and MIN with the MAX. and MIN. prefix operators. DEFINE fields cannot include prefix operators.
Note: FML report requests are extended TABLE requests. The Financial Modeling Language provides special functions for detailed reporting. Consult your FOCUS documentation for more information.
In addition, IF-THEN-ELSE optimization does not support the following features:
How to: |
Reference: |
The Adapter for Microsoft Azure SQL Data Warehouse supports array retrieval from result sets produced by executing SELECT queries or stored procedures. This technique substantially reduces network traffic and CPU utilization.
Using high values increases the efficiency of requests involving many rows, at the cost of higher virtual storage requirements. A value higher than 100 is not recommended because the increased efficiency it would provide is generally negligible.
Tip: You can change this setting manually or from the Web Console by clicking Adapters on the sidebar, right-clicking a configured adapter, and choosing Change Settings from the right-click menu. The Change Settings pane opens.
The block size for a SELECT request applies to TABLE FILE requests, MODIFY requests, MATCH requests, and DIRECT SQL SELECT statements.
ENGINE SQLADW SET FETCHSIZE n
where:
Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.
Is the number of rows to be retrieved at once using array retrieval techniques. Accepted values are 1 to 5000. The default varies by adapter. If the result set contains a column that has to be processed as a CLOB or a BLOB, the FETCHSIZE value used for that result set is 1.
In combination with LOADONLY, the block size for an INSERT applies to MODIFY INCLUDE requests. INSERTSIZE is also supported for parameterized DIRECT SQL INSERT statements.
ENGINE SQLADW SET INSERTSIZE n
where:
Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.
Is the number of rows to be inserted using array insert techniques. Accepted values are 1 to 5000. 1 is the default value. If the result set contains a column that has to be processed as a BLOB, the INSERTSIZE value used for that result set is 1.
ENGINE SQLADW SET BULKLOAD [ON|OFF]
where:
Indicates the adapter. You can omit this value if you previously issued the SET SQLENGINE command.
Uses the Bulk Insert API. ON is the default.
Suppresses the use of the Bulk Insert API.
You can use DataMigrator with the Bulk Insert API for Microsoft Azure SQL Data Warehouse.
For the Adapter for Microsoft Azure SQL Data Warehouse, the Bulk API is used automatically in LOADONLY mode. Measurements show that intermediate flushes do not affect performance; therefore, the behavior does not depend on the INSERTSIZE.
Errors that occur during the load (such as duplication) can cause the batch of rows to be rejected as a whole.
How to: |
Reference: |
A left outer join selects all records from the host table and matches them with records from the cross-referenced table. When no matching records exist, the host record is still retained, and default values (blank or zero) are assigned to the cross-referenced fields. The adapter can optimize any WHERE-based left outer join command in which the conditional expression is supported by the RDBMS.
JOIN LEFT_OUTER FILE hostfile AT hfld1 [TAG tag1] [WITH hfld2] TO {UNIQUE|MULTIPLE} FILE crfile AT crfld [TAG tag2] [AS joinname] [WHERE expression1; [WHERE expression2; ...] END
where:
Specifies a left outer join. If you do not specify the type of join in the JOIN command, the ALL parameter setting determines the type of join to perform.
Is the host Master File.
Links the correct parent segment or host to the correct child or cross-referenced segment. The field values used as the AT parameter are not used to cause the link. They are used as segment references.
Is the field name in the host Master File whose segment will be joined to the cross-referenced data source. The field name must be at the lowest level segment in its data source that is referenced.
Is the optional tag name that is used as a unique qualifier for fields and aliases in the host data source.
Is a data source field with which to associate a DEFINE-based conditional JOIN. For a DEFINE-based conditional join, the KEEPDEFINES setting must be ON, and you must create the virtual fields before issuing the JOIN command.
Specifies a one-to-many relationship between from_file and to_file. Note that ALL is a synonym for MULTIPLE.
Specifies a one-to-one relationship between hostfile and crfile. Note that ONE is a synonym for UNIQUE.
Note: Unique returns only one instance and, if there is no matching instance in the cross-referenced file, it supplies default values (blank for alphanumeric fields and zero for numeric fields).
The unique join is a WebFOCUS concept. The RDBMS makes no distinction between unique and non-unique situations. It always retrieves all matching rows from the cross-referenced file.
If the RDBMS processes a join that the request specifies as unique, and if there are, in fact, multiple corresponding rows in the cross-referenced file, the RDBMS returns all matching rows. If, instead, optimization is disabled so that WebFOCUS processes the join, a different report results because WebFOCUS, respecting the unique join concept, returns only one cross-referenced row for each host row.
Is the cross-referenced Master File.
Is the join field name in the cross-referenced Master File. It can be any field in the segment.
Is the optional tag name that is used as a unique qualifier for fields and aliases in the cross-referenced data source.
Is the name associated with the joined structure.
Are any expressions that are acceptable in a DEFINE FILE command. All fields used in the expressions must lie on a single path.
or
or
The following request creates a left outer conditional join between two MSSQL data sources and reports against the joined data sources. The STMTRACE is turned on in order to view the SQL generated for this request:
SET TRACEUSER = ON SET TRACEOFF = ALL SET TRACEON = STMTRACE//CLIENT JOIN LEFT_OUTER FILE employee AT EMPLOYEEID TO ALL FILE employeepayhistory AT EMPLOYEEID WHERE RATECHANGEDATE GT HIREDATE; END TABLE FILE employee PRINT RATE BY EMPLOYEEID END
The WebFOCUS request is translated to a single MSSQL SELECT statement that incorporates the left outer join, and the non-equality condition is passed to the RDBMS in the ON clause:
SELECT T1."EmployeeID", T1."HireDate", T2."EmployeeID", T2."RateChangeDate", T2."Rate" FROM AdventureWorks.HumanResources.Employee T1 LEFT OUTER JOIN AdventureWorks.HumanResources.EmployeePayHistory T2 ON (T2."RateChangeDate" > T1."HireDate") ) ORDER BY T1."EmployeeID";
WebFOCUS | |
Feedback |