简体   繁体   中英

slow mysql connection to server

We use Yii v1.1.13 and mysql Ver 14.14 Distrib 5.5.32

We have 2 servers (server1, server2) using the same DB on server2.

When I send request from server2 using yiic

$list= Yii::app()->db->createCommand('select * from foo')->queryAll();

download speed is about 140-200KB/s,

but when I run something like

Foo::model()->findAll();

download speed is about 10-20KB/s

What may cause it, may be smth wrong is with AR?

Active Record will be much slower than a raw sql query.

There are things that you can do to speed it up like caching.

Also, the Foo::model() is more than just a mysql result set. It is a data model with much more information and much more versatile than a database table.

also, I havent used Yii so I may be wrong, but should you be doing createcommand($sql)->queryall(); ? Surely a comparative statement would be createcommand($sql)->execute() ?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM