&引用;“不存在”;或;“存在”;分页查询在cakephp中执行时间过长
我正在尝试使用“notexists”和“exists”命令获取记录 芬德尔的工作很好。。但随着分页“最大加入大小”问题的出现 代码:&引用;“不存在”;或;“存在”;分页查询在cakephp中执行时间过长,php,cakephp,pagination,cakephp-2.0,Php,Cakephp,Pagination,Cakephp 2.0,我正在尝试使用“notexists”和“exists”命令获取记录 芬德尔的工作很好。。但随着分页“最大加入大小”问题的出现 代码: $this->User->unbindModelAll(); $this->Booking->unbindModelAll(); $this->User->bindModel(array('hasMany' => array('UserImage'), 'hasOne' =>array('Booking','Rent
$this->User->unbindModelAll();
$this->Booking->unbindModelAll();
$this->User->bindModel(array('hasMany' => array('UserImage'), 'hasOne' =>array('Booking','RentalGoal', 'Verification', 'AbcCheck')), false);
$cond_user = array(
'User.id NOT' => $a,
'User.is_hide' =>1, 'User.status' =>1,
'RentalGoal.looking_for' =>1,'RentalGoal.room_type <>' => null, 'RentalGoal.step1_completed' =>1, 'Verification.rent_gaol' => 1,
'OR'=>array(
array('not exists ' . '(select id from dev_bookings ' . 'where dev_bookings.user_id = ' . 'User.id AND dev_bookings.move_in =1 AND dev_bookings.move_out = 0 AND dev_bookings.rent_term = "m")'),
array('exists ' . '(select id from dev_user_images ' . 'where dev_user_images.user_id = ' . 'User.id AND dev_user_images.status =1 AND dev_user_images.default = 1)'),
false),);
但不使用paginate
$this->paginate = array(
'conditions' => $cond_user,
'limit' =>100,
'recursive' =>2,
'order' => array('User.user_verification DESC'),
);
$new_arr = $this->paginate('User');
错误>
2014-07-04 14:38:51 Error: [PDOException] SQLSTATE[42000]: Syntax error or access violation: 1104 The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
AppModel>
class AppModel extends Model {
function beforeFind($query)
{
$this->query('SET SQL_BIG_SELECTS=1');
}
}
有什么问题吗?我也用,假成绑定模型
请帮忙
谢谢MySQL根据“max\u join\u size”的值确定查询是否为“大选择”。如果查询可能需要检查超过这个行数,它会认为它是一个“大选择”。使用“显示变量”查看最大联接大小的值 我相信索引和一个特殊的good where子句可以防止这个问题的发生 SQL_BIG_SELECTS用于防止用户意外执行过大的查询。可以在mysql.cnf中将其设置为ON,也可以在启动时使用命令行选项 您可以在my.cnf或服务器启动时设置SQL\u BIG\u选择。也可以在会话基础上使用“set session SQL\u BIG\u SELECTS=1”来设置它 我想不出来。我会检查您的查询,以确保您确实需要使用它。我们的服务器在默认情况下已打开,并且最大加入大小非常大 设置最大连接大小 设置全局最大连接大小=1844674407370955148795
class AppModel extends Model {
function beforeFind($query)
{
$this->query('SET SQL_BIG_SELECTS=1');
}