Project Wonder 5.0

er.extensions.jdbc
Class ERXSQLHelper.FrontBaseSQLHelper

java.lang.Object
  extended by er.extensions.jdbc.ERXSQLHelper
      extended by er.extensions.jdbc.ERXSQLHelper.FrontBaseSQLHelper
Enclosing class:
ERXSQLHelper

public static class ERXSQLHelper.FrontBaseSQLHelper
extends ERXSQLHelper


Nested Class Summary
 
Nested classes/interfaces inherited from class er.extensions.jdbc.ERXSQLHelper
ERXSQLHelper.ColumnIndex, ERXSQLHelper.CustomTypes, ERXSQLHelper.DerbySQLHelper, ERXSQLHelper.EROracleSQLHelper, ERXSQLHelper.FrontBaseSQLHelper, ERXSQLHelper.H2SQLHelper, ERXSQLHelper.MicrosoftSQLHelper, ERXSQLHelper.MySQLSQLHelper, ERXSQLHelper.NoSQLHelper, ERXSQLHelper.OpenBaseSQLHelper, ERXSQLHelper.OracleSQLHelper, ERXSQLHelper.PostgresqlSQLHelper
 
Field Summary
 
Fields inherited from class er.extensions.jdbc.ERXSQLHelper
log
 
Constructor Summary
ERXSQLHelper.FrontBaseSQLHelper()
           
 
Method Summary
protected  java.util.regex.Pattern commentPattern()
          Returns a pattern than matches lines that start with "--".
 java.lang.String limitExpressionForSQL(com.webobjects.eoaccess.EOSQLExpression expression, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, java.lang.String sql, long start, long end)
           
protected  int maximumElementPerInClause(com.webobjects.eoaccess.EOEntity entity)
          FrontBase is exceedingly inefficient in processing OR clauses.
 void prepareConnectionForSchemaChange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eoaccess.EOModel model)
           
 java.lang.String quoteColumnName(java.lang.String columnName)
           
 boolean reassignExternalTypeForValueTypeOverride(com.webobjects.eoaccess.EOAttribute attribute)
           
 void restoreConnectionSettingsAfterSchemaChange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eoaccess.EOModel model)
           
 boolean shouldExecute(java.lang.String sql)
           
 java.lang.String sqlForCreateIndex(java.lang.String indexName, java.lang.String tableName, ERXSQLHelper.ColumnIndex... columnIndexes)
          Returns the SQL expression for creating an index on the given set of columns
 java.lang.String sqlForCreateUniqueIndex(java.lang.String indexName, java.lang.String tableName, ERXSQLHelper.ColumnIndex... columnIndexes)
          Returns the SQL expression for creating a unique index on the given set of columns
 java.lang.String sqlForFullTextQuery(ERXFullTextQualifier qualifier, com.webobjects.eoaccess.EOSQLExpression expression)
          Returns the SQL expression for a full text search query.
protected  java.lang.String sqlForGetNextValFromSequencedNamed(java.lang.String sequenceName)
          Returns the SQL required to select the next value from the given sequence.
 
Methods inherited from class er.extensions.jdbc.ERXSQLHelper
_groupByOrHavingIndex, _orderByIndex, addGroupByClauseToExpression, addGroupByClauseToExpression, addHavingCountClauseToExpression, appendItemToListString, attributesToFetchForEntity, canReliablyPerformDistinctWithSortOrderings, columnIndexesFromColumnNames, columnNamesFromColumnIndexes, commandSeparatorChar, commandSeparatorString, createDependentSchemaSQLForEntities, createIndexSQLForEntities, createIndexSQLForEntities, createSchemaSQLForEntitiesInDatabaseContext, createSchemaSQLForEntitiesInModel, createSchemaSQLForEntitiesInModelAndOptions, createSchemaSQLForEntitiesInModelWithName, createSchemaSQLForEntitiesInModelWithNameAndOptions, createSchemaSQLForEntitiesWithOptions, createSchemaSQLForEntitiesWithOptions, customQueryExpressionHintAsString, defaultOptionDictionary, externalTypeForJDBCType, formatValueForAttribute, getNextValFromSequenceNamed, handleDatabaseException, jdbcTypeForCustomType, migrationTableName, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, readFormatForAggregateFunction, removeSelectFromExpression, rowCountForFetchSpecification, shouldPerformDistinctInMemory, splitSQLStatements, splitSQLStatementsFromFile, splitSQLStatementsFromInputStream, sqlExpressionForFetchSpecification, sqlExpressionForFetchSpecification, sqlForCreateIndex, sqlForCreateUniqueIndex, sqlForRegularExpressionQuery, sqlForSubquery, sqlWhereClauseStringForKey, varcharLargeColumnWidth, varcharLargeJDBCType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXSQLHelper.FrontBaseSQLHelper

public ERXSQLHelper.FrontBaseSQLHelper()
Method Detail

reassignExternalTypeForValueTypeOverride

public boolean reassignExternalTypeForValueTypeOverride(com.webobjects.eoaccess.EOAttribute attribute)
Overrides:
reassignExternalTypeForValueTypeOverride in class ERXSQLHelper

sqlForGetNextValFromSequencedNamed

protected java.lang.String sqlForGetNextValFromSequencedNamed(java.lang.String sequenceName)
Description copied from class: ERXSQLHelper
Returns the SQL required to select the next value from the given sequence. This should return a single row with a single column.

Overrides:
sqlForGetNextValFromSequencedNamed in class ERXSQLHelper
Parameters:
sequenceName - the name of the sequence
Returns:
the next sequence value

shouldExecute

public boolean shouldExecute(java.lang.String sql)
Overrides:
shouldExecute in class ERXSQLHelper

limitExpressionForSQL

public java.lang.String limitExpressionForSQL(com.webobjects.eoaccess.EOSQLExpression expression,
                                              com.webobjects.eocontrol.EOFetchSpecification fetchSpecification,
                                              java.lang.String sql,
                                              long start,
                                              long end)
Overrides:
limitExpressionForSQL in class ERXSQLHelper

sqlForFullTextQuery

public java.lang.String sqlForFullTextQuery(ERXFullTextQualifier qualifier,
                                            com.webobjects.eoaccess.EOSQLExpression expression)
Description copied from class: ERXSQLHelper
Returns the SQL expression for a full text search query.

Overrides:
sqlForFullTextQuery in class ERXSQLHelper
Parameters:
qualifier - the full text qualifier
expression - the EOSQLExpression context
Returns:
a SQL expression

sqlForCreateUniqueIndex

public java.lang.String sqlForCreateUniqueIndex(java.lang.String indexName,
                                                java.lang.String tableName,
                                                ERXSQLHelper.ColumnIndex... columnIndexes)
Description copied from class: ERXSQLHelper
Returns the SQL expression for creating a unique index on the given set of columns

Overrides:
sqlForCreateUniqueIndex in class ERXSQLHelper
Parameters:
indexName - the name of the index to create
tableName - the name of the containing table
columnIndexes - the list of columns to index on
Returns:
a SQL expression

sqlForCreateIndex

public java.lang.String sqlForCreateIndex(java.lang.String indexName,
                                          java.lang.String tableName,
                                          ERXSQLHelper.ColumnIndex... columnIndexes)
Description copied from class: ERXSQLHelper
Returns the SQL expression for creating an index on the given set of columns

Overrides:
sqlForCreateIndex in class ERXSQLHelper
Parameters:
indexName - the name of the index to create
tableName - the name of the containing table
columnIndexes - the list of columns to index on
Returns:
a SQL expression

prepareConnectionForSchemaChange

public void prepareConnectionForSchemaChange(com.webobjects.eocontrol.EOEditingContext ec,
                                             com.webobjects.eoaccess.EOModel model)
Overrides:
prepareConnectionForSchemaChange in class ERXSQLHelper

restoreConnectionSettingsAfterSchemaChange

public void restoreConnectionSettingsAfterSchemaChange(com.webobjects.eocontrol.EOEditingContext ec,
                                                       com.webobjects.eoaccess.EOModel model)
Overrides:
restoreConnectionSettingsAfterSchemaChange in class ERXSQLHelper

commentPattern

protected java.util.regex.Pattern commentPattern()
Returns a pattern than matches lines that start with "--".

Overrides:
commentPattern in class ERXSQLHelper
Returns:
regex pattern that indicates this line is an SQL comment

quoteColumnName

public java.lang.String quoteColumnName(java.lang.String columnName)
Overrides:
quoteColumnName in class ERXSQLHelper

maximumElementPerInClause

protected int maximumElementPerInClause(com.webobjects.eoaccess.EOEntity entity)
FrontBase is exceedingly inefficient in processing OR clauses. A query like this:
SELECT * FROM "Foo" t0 WHERE ( t0."oid" IN (431, 437, ...) OR t0."oid" IN (1479, 1480, 1481,...)...
Completely KILLS FrontBase (30+ seconds of 100%+ CPU usage). The same query rendered as:
SELECT * FROM "Foo" t0 WHERE t0."oid" IN (431, 437, ...) UNION SELECT * FROM "Foo" t0 WHERE t0."oid" IN (1479, 1480, 1481, ...)... executes in less than a tenth of the time with less high CPU load. Collapse all the ORs and INs into one and it is faster still. This has been tested with over 17,000 elements, so 15,000 seemed like a safe maximum. I don't know what the actual theoretical maximum is. But... It looks to like the query optimizer will choose to NOT use an index if the number of elements in the IN gets close to, or exceeds, the number of rows (as in the case of a select based on FK with a large number of keys that don't match any rows). In this case it seems to fall back to table scanning (or something dreadfully slow). This only seems to have an impact when the number of elements in the IN is greater than 1,000. For larger sizes, the correct number for this method to return seems to depend on the number of rows in the tables. 1/5th of the table size may be a good place to start looking for the upper bound.

Overrides:
maximumElementPerInClause in class ERXSQLHelper
Parameters:
entity - EOEntity that can be used to fine-tune the result
Returns:
database specific limit, or or most efficient number, of elements in an IN clause in a statement
See Also:
ERXSQLHelper#maximumElementPerInClause()

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.