public static class ERXSQLHelper.FrontBaseSQLHelper extends ERXSQLHelper
ERXSQLHelper.ColumnIndex, ERXSQLHelper.CustomTypes, ERXSQLHelper.DB2SQLHelper, ERXSQLHelper.DerbySQLHelper, ERXSQLHelper.EROracleSQLHelper, ERXSQLHelper.FirebirdSQLHelper, ERXSQLHelper.FrontBaseSQLHelper, ERXSQLHelper.H2SQLHelper, ERXSQLHelper.MicrosoftSQLHelper, ERXSQLHelper.MySQLSQLHelper, ERXSQLHelper.NoSQLHelper, ERXSQLHelper.OpenBaseSQLHelper, ERXSQLHelper.OracleSQLHelper, ERXSQLHelper.PostgresqlSQLHelper
Constructor and Description |
---|
FrontBaseSQLHelper() |
Modifier and Type | Method and Description |
---|---|
protected Pattern |
commentPattern()
Returns a pattern than matches lines that start with "--".
|
String |
externalTypeForJDBCType(com.webobjects.jdbcadaptor.JDBCAdaptor adaptor,
int jdbcType)
For BOOLEAN we take 'boolean' as external type.
|
String |
limitExpressionForSQL(com.webobjects.eoaccess.EOSQLExpression expression,
com.webobjects.eocontrol.EOFetchSpecification fetchSpecification,
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) |
String |
quoteColumnName(String columnName) |
boolean |
reassignExternalTypeForValueTypeOverride(EOAttribute attribute) |
void |
restoreConnectionSettingsAfterSchemaChange(com.webobjects.eocontrol.EOEditingContext ec,
com.webobjects.eoaccess.EOModel model) |
boolean |
shouldExecute(String sql) |
String |
sqlForCreateIndex(String indexName,
String tableName,
ERXSQLHelper.ColumnIndex... columnIndexes)
Returns the SQL expression for creating an index on the given set
of columns
|
String |
sqlForCreateUniqueIndex(String indexName,
String tableName,
ERXSQLHelper.ColumnIndex... columnIndexes)
Returns the SQL expression for creating a unique index on the given set
of columns
|
String |
sqlForFullTextQuery(ERXFullTextQualifier qualifier,
com.webobjects.eoaccess.EOSQLExpression expression)
Returns the SQL expression for a full text search query.
|
protected String |
sqlForGetNextValFromSequencedNamed(String sequenceName)
Returns the SQL required to select the next value from the given sequence.
|
_groupByOrHavingIndex, _orderByIndex, addGroupByClauseToExpression, addGroupByClauseToExpression, addHavingCountClauseToExpression, appendItemToListString, attributesToFetchForEntity, canReliablyPerformDistinctWithSortOrderings, columnIndexesFromColumnNames, columnNamesFromColumnIndexes, commandSeparatorChar, commandSeparatorString, createDependentSchemaSQLForEntities, createIndexSQLForEntities, createIndexSQLForEntities, createSchemaSQLForEntitiesInDatabaseContext, createSchemaSQLForEntitiesInModel, createSchemaSQLForEntitiesInModelAndOptions, createSchemaSQLForEntitiesInModelWithName, createSchemaSQLForEntitiesInModelWithNameAndOptions, createSchemaSQLForEntitiesWithOptions, createSchemaSQLForEntitiesWithOptions, customQueryExpressionHintAsString, defaultOptionDictionary, formatValueForAttribute, getNextValFromSequenceNamed, handleDatabaseException, jdbcTypeForCustomType, migrationTableName, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, newSQLHelper, readFormatForAggregateFunction, readFormatForAggregateFunction, removeSelectFromExpression, rowCountForFetchSpecification, shouldPerformDistinctInMemory, splitSQLStatements, splitSQLStatementsFromFile, splitSQLStatementsFromInputStream, sqlExpressionForFetchSpecification, sqlExpressionForFetchSpecification, sqlForCountDistinct, sqlForCreateIndex, sqlForCreateUniqueIndex, sqlForRegularExpressionQuery, sqlForSubquery, sqlWhereClauseStringForKey, varcharLargeColumnWidth, varcharLargeJDBCType
public boolean reassignExternalTypeForValueTypeOverride(EOAttribute attribute)
reassignExternalTypeForValueTypeOverride
in class ERXSQLHelper
protected String sqlForGetNextValFromSequencedNamed(String sequenceName)
ERXSQLHelper
sqlForGetNextValFromSequencedNamed
in class ERXSQLHelper
sequenceName
- the name of the sequencepublic boolean shouldExecute(String sql)
shouldExecute
in class ERXSQLHelper
public String limitExpressionForSQL(com.webobjects.eoaccess.EOSQLExpression expression, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification, String sql, long start, long end)
limitExpressionForSQL
in class ERXSQLHelper
public String sqlForFullTextQuery(ERXFullTextQualifier qualifier, com.webobjects.eoaccess.EOSQLExpression expression)
ERXSQLHelper
sqlForFullTextQuery
in class ERXSQLHelper
qualifier
- the full text qualifierexpression
- the EOSQLExpression contextpublic String sqlForCreateUniqueIndex(String indexName, String tableName, ERXSQLHelper.ColumnIndex... columnIndexes)
ERXSQLHelper
sqlForCreateUniqueIndex
in class ERXSQLHelper
indexName
- the name of the index to createtableName
- the name of the containing tablecolumnIndexes
- the list of columns to index onpublic String sqlForCreateIndex(String indexName, String tableName, ERXSQLHelper.ColumnIndex... columnIndexes)
ERXSQLHelper
sqlForCreateIndex
in class ERXSQLHelper
indexName
- the name of the index to createtableName
- the name of the containing tablecolumnIndexes
- the list of columns to index onpublic void prepareConnectionForSchemaChange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eoaccess.EOModel model)
prepareConnectionForSchemaChange
in class ERXSQLHelper
public void restoreConnectionSettingsAfterSchemaChange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eoaccess.EOModel model)
restoreConnectionSettingsAfterSchemaChange
in class ERXSQLHelper
protected Pattern commentPattern()
commentPattern
in class ERXSQLHelper
public String quoteColumnName(String columnName)
quoteColumnName
in class ERXSQLHelper
protected int maximumElementPerInClause(com.webobjects.eoaccess.EOEntity entity)
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.
maximumElementPerInClause
in class ERXSQLHelper
entity
- EOEntity that can be used to fine-tune the resultERXSQLHelper.maximumElementPerInClause(EOEntity)
public String externalTypeForJDBCType(com.webobjects.jdbcadaptor.JDBCAdaptor adaptor, int jdbcType)
externalTypeForJDBCType
in class ERXSQLHelper
adaptor
- the adaptor to retrieve an external type forjdbcType
- the JDBC type numberCopyright © 2002 – 2020 Project Wonder.