0

I have:

  • A linux server with PHP 5.3.2 and Apache 2.0
  • A windows Server with SQL SERVER

I connect my linux server with database with unixODBC 2.3.1 and FREETDS 0.9.1

The connection is okay but the queries are slow. Here is my code that generate the image below:

$this->adodb->LogSQL(true); // turn on logging
$query = "select c.name, t.name, c.length from syscolumns c join systypes t on t.xusertype = c.xusertype
          join sysobjects o on o.id=c.id where o.name = 'CONDOMINIO'";
$res = $this->adodb->Execute($query);
$this->adodb->LogSQL(false); // turn off logging
$perf = NewPerfMonitor($this->adodb);
echo $perf->SuspiciousSQL();
echo $perf->ExpensiveSQL();

Image http://www.vigoonline.net/slow.png

As you can see, the first query has an average time of 4.68 seconds, which is way too slow.

If I execute the same query like this:

$this->adodb->_query($query);

Then the time to execute the query takes less than a second what is great. Has anyone else experienced the same thing?

The query called with "Execute" is used for the own class for bringing the "MetaColumns" information from the table

The table "CONDOMINIO" only has 21 rows.

If the server database is in the same machine with the application script, then the response is fast!

4

1 回答 1

1

我自己解决了这个问题。这是我所做的:

转到文件/adodb/drivers/adodb-odbc.inc.php和班级ADODB_odbc

在这里尝试找到:

var $curmode = SQL_CUR_USE_DRIVER

并将其更改为:

var $curmode = SQL_CUR_USE_IF_NEEDED;

这将使连接SQL_CUR_USE_ODBC在需要时使用,并且“瞧”数据库对 SQL 服务器的访问速度非常快!

于 2012-09-18T14:43:36.207 回答