IDO Queries: performance quickfixes
Will be obsoleted by the new filter implementation, but for now it helps a little bit
This commit is contained in:
parent
b447225512
commit
e6d80ae1f6
|
@ -75,7 +75,12 @@ class TreeToSqlParser
|
|||
if (count($right) > 1) {
|
||||
return 'IN';
|
||||
} else {
|
||||
return 'LIKE';
|
||||
foreach ($right as $r) {
|
||||
if (strpos($r, '*') !== false) {
|
||||
return 'LIKE';
|
||||
}
|
||||
}
|
||||
return '=';
|
||||
}
|
||||
case Node::OPERATOR_EQUALS_NOT:
|
||||
if (count($right) > 1) {
|
||||
|
@ -171,7 +176,11 @@ class TreeToSqlParser
|
|||
if ($node->context === Node::CONTEXT_TIMESTRING && !is_numeric($value)) {
|
||||
$value = strtotime($value);
|
||||
}
|
||||
$values[] = $this->query->getDatasource()->getConnection()->quote($value);
|
||||
if (preg_match('/^\d+$/', $value)) {
|
||||
$values[] = $value;
|
||||
} else {
|
||||
$values[] = $this->query->getDatasource()->getConnection()->quote($value);
|
||||
}
|
||||
}
|
||||
$valueString = join(',', $values);
|
||||
|
||||
|
|
|
@ -113,9 +113,9 @@ class ContactgroupQuery extends IdoQuery
|
|||
+-------------------------+-------------+------------+------------------------+
|
||||
*/
|
||||
|
||||
$this->baseQuery->join(
|
||||
// array('scg' => $this->prefix . 'service_contactgroups'),
|
||||
array('scg' => $scgSub),
|
||||
$this->baseQuery->distinct()->join(
|
||||
array('scg' => $this->prefix . 'service_contactgroups'),
|
||||
// array('scg' => $scgSub),
|
||||
'scg.contactgroup_object_id = cg.contactgroup_object_id',
|
||||
array()
|
||||
)->join(
|
||||
|
|
|
@ -14,11 +14,23 @@ class CustomvarQuery extends IdoQuery
|
|||
'service_host_name' => 'cvo.name1 COLLATE latin1_general_ci',
|
||||
'service_description' => 'cvo.name2 COLLATE latin1_general_ci',
|
||||
'contact_name' => 'cvo.name1 COLLATE latin1_general_ci',
|
||||
'object_type' => "CASE cvo.objecttype_id WHEN 1 THEN 'host' WHEN 2 THEN 'service' WHEN 10 THEN 'contact' ELSE 'invalid' END"
|
||||
'object_type' => "CASE cvo.objecttype_id WHEN 1 THEN 'host' WHEN 2 THEN 'service' WHEN 10 THEN 'contact' ELSE 'invalid' END",
|
||||
'object_type_id' => 'cvo.objecttype_id'
|
||||
// 'object_type' => "CASE cvo.objecttype_id WHEN 1 THEN 'host' WHEN 2 THEN 'service' WHEN 3 THEN 'hostgroup' WHEN 4 THEN 'servicegroup' WHEN 5 THEN 'hostescalation' WHEN 6 THEN 'serviceescalation' WHEN 7 THEN 'hostdependency' WHEN 8 THEN 'servicedependency' WHEN 9 THEN 'timeperiod' WHEN 10 THEN 'contact' WHEN 11 THEN 'contactgroup' WHEN 12 THEN 'command' ELSE 'other' END"
|
||||
),
|
||||
);
|
||||
|
||||
public function where($expression, $parameters = null)
|
||||
{
|
||||
$types = array('host' => 1, 'service' => 2, 'contact' => 10);
|
||||
if ($expression === 'object_type') {
|
||||
parent::where('object_type_id', $types[$parameters]);
|
||||
} else {
|
||||
parent::where($expression, $parameters);
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
$this->baseQuery = $this->db->select()->from(
|
||||
|
|
Loading…
Reference in New Issue