Optimizer OverridesContents
OverviewStandardsSQL standard doesnât specify a way of providing optimizer overrides and hence the proposal here is to include these overrides in SQL comments. That implementation choice will make sure that when the SQL with optimizer override comments is ported to some other database, it will not break. Chances are that the optimizer overrides provided through SQL comments will be ignored by other SQL engines. ORACLE supports optimizer hints through SQL comments. Sybase has WITH table-hint option in the FROM clause of the SQL statement to support optimization hints. Functionality--PROPERTIES propertyName = value [, propertyName = value]* Notice, there is no space between -- and PROPERTIES. Optimizer override properties can be specified for an entire FROM clause and/or for tables in the FROM clause. Syntax for FROM clause properties   FROM [ --PROPERTIES joinOrder = { FIXED | UNFIXED}]       TableExpression [,TableExpression]*
Syntax for table optimizer override properties (this come at the end of TableExpression, like following)   {TableName | ViewName }       [ [ AS ] CorrelationName        [ (SimpleColumnName [ , SimpleColumnName]* ) ] ]        [--PROPERTIES clause]
Following will be the supported properties 1)
constraint â The Derby optimizer chooses an index, including the indexes that
enforce constraints, as the access path for query execution if it is useful. If
there is more than one useful index, in most cases, 2) index â This is similar to constraint property. To force use of a particular index, specify the unqualified index name. To force a table scan, specify null for the index name. 3) joinOrder â Will allow users to override the optimizerâs choice of join order for two tables. When the value FIXED will be used, the optimizer will choose the order of tables as they appear in the FROM clause as the join order. 4)
joinStrategy â This property will allow users to override the optimizerâs
choice of join strategy. The 2 types of join strategy are called nested loop
and hash. In a nested loop join strategy, for each qualifying row in the outer table,
With the exception of joinStrategy (which is allowed on all table expressions), constraint and index can be specified only on base tables; they are not allowed on views or derived tables. Design OverviewThe
main hurdle in implementing this feature is to have parser distinguish between
a user comment starting with -- and optimizer overrides starting with
--PROPERTIES. The properties mentioned above are already recognized by Availability under Network ServerThese optimizer overrides should work under Network Server too since the sql will be passed by the client to the server (along with all the comments). DocumentationThese overrides will need to be documented. MiscellaneousIf the
user will not follow --PROPERTIES syntax for specifying the optimizer overrides,
parser will simply treat them as comments and ignore them. So, be careful with
the syntax, donât leave any blanks between -- and PROPERTIES. The parser can
always be modified to be more flexible about this syntax but this is what I am
shooting for at this point.
|
Hi,
I am looking at implementing optimizer overrides in Derby for 10.2 release. Derby engine in fact already supports some optimizer overrides but they are not user visible. I have attached the functional spec for more information. Let me know if anyone has any comments.
thanks,
Mamta
Title: Optimizer Overrides
- Optimizer overrides - functional spec Mamta Satoor
- Re: Optimizer overrides - functional spec Jeffrey Lichtman
- Re: Optimizer overrides - functional spec Mamta Satoor
- Re: Optimizer overrides - functional spec Daniel John Debrunner
- Re: Optimizer overrides - functional spec Mamta Satoor
- Re: Optimizer overrides - functional spec Øystein Grøvlen
