query returns quite slowly.. Do you know what should be done to improve the performance? Thanks
$where[] = "FIND_IN_SET(:pid, users.parents)";
$args['books'] = $this->query("SELECT books.*, users.user,
(SELECT COUNT(id) FROM {$this->prefix}books_best WHERE book_id = books.id) AS book_count,
(SELECT COUNT(id) FROM {$this->prefix}books_best WHERE book_id = books.id AND status > 1) AS result_count
FROM {$this->prefix}books AS books
INNER JOIN {$this->prefix}users AS users ON users.id = books.user_id
".(isset($_REQUEST['team']) && !empty($_REQUEST['team']) ? "
INNER JOIN {$this->prefix}books_best AS tcb ON tcb.book_id = books.id
INNER JOIN {$this->prefix}book_played AS tm ON tm.id = tcb.book_id AND (tm.home LIKE :team OR tm.away LIKE :team)
" : "")."
".(isset($_REQUEST['book_id']) && !empty($_REQUEST['book_id']) ? "
INNER JOIN {$this->prefix}books_best AS mcb ON mcb.book_id = books.id AND mcb.book_id = ".intval($_REQUEST['book_id'])."
" : "")."
".(count($array) > 0 ? "WHERE ".implode(" AND ", $where) : "")."
ORDER BY {$orders[$orderable['type']]} {$orderable['order']}
", $array, array('counter' => 'books.id', 'limit' => $_REQUEST['limit'] ?? 25));
$args['pagination'] = $this->pagination();