ZF-5169: QSYS2.SYSCOLUMNS not limiting search by SCHEMA in Zend_Db_Adapter_Db2::describeTable()

Description

The $schemaName variable passed to Zend_Db_Adapter_Db2::describeTable() is not being set to the schema name defined in the default adapter. This is causing the function to scan the entire QSYS2 table when it should only be looking for matches for the schema named in the adapter. Our QSYS2 table contains over 1,000,000 records. This causes a tremendous slowdown since the table is scanned once for each query; some screens querying over a dozen tables.

A check is performed in the describeTable() method to see if $schemaName is set. In every case it is not. The adapter has a variable which is set containing the schema name ($this->_config['schema']). I modified my version of the adapter to check for $this->_config['schema'] rather than the passed $schemaName variable and use its value and it's now running much faster.

I did notice that if I explicitly set the schema name for a given model the queries work as expected (i.e. the query only checks the schema indicated). Must this be done? It seems to defeat the purpose of setting the schema in the adapter to have set it again for each model; all of which use the same adapter. Shouldn't the adapter pass the schema name on if it's not set in the model?

Please forgive me if this post is a duplicate.

I am running a copy of the DB2 adapter found here: http://framework.zend.com/code/changelog/…

You will find information about my system settings in the following thread: ZF-4501

Comments

Hi, Simon.

Do you mean that the schema name must be required in __construct() of Zend_Db_Adapter_Db2 ?

I'm not sure if the schema name should be required in the constructor. I would think that it would not be required. The issue we are having is that the schema name IS set in the constructor but is not being passed to the describeTable() method in the adapter (it's an optional second parameter).

It seems to me that if the schema name is set in the constructor it should be passed into this function by default. This is currently not the case for me.

This is on my radar, I am getting our i5 instance repartitioned at the moment, so once thats going I am gonna work on persisting the _schema in the i5 describeTable() method.

Hi, Simon and Ralph.

I have an idea as following skelton.


protected $_schema;

public function __construct($config){
    parent::__construct($config);
    if(isset($config['schema']){
        $this->_schema = $config['schema'];
    }
}

public function describeTable($tableName, $schemaName = $this->_schema){
}

If You give schema on __construct, You can use as default value.

is this still an issue in the adapter in 1.7.2?

I confirm today that this issue have been fixed at 1.7.2 .