Optimize index-usage

This commit is contained in:
int2001
2026-02-03 11:51:07 +00:00
parent a81a165324
commit 48751e3f2e
12 changed files with 147 additions and 133 deletions

View File

@@ -325,12 +325,12 @@ class Contesting_model extends CI_Model {
if ($from != 0) {
$from = DateTime::createFromFormat('Y-m-d', $this->security->xss_clean($from));
$from = $from->format('Y-m-d');
$this->db->where("date(" . $this->config->item('table_name') . ".COL_TIME_ON) >= '" . $from . "'");
$this->db->where($this->config->item('table_name') . ".COL_TIME_ON >= '" . $from . " 00:00:00'");
}
if ($to != 0) {
$to = DateTime::createFromFormat('Y-m-d', $this->security->xss_clean($to));
$to = $to->format('Y-m-d');
$this->db->where("date(" . $this->config->item('table_name') . ".COL_TIME_ON) <= '" . $to . "'");
$this->db->where($this->config->item('table_name') . ".COL_TIME_ON <= '" . $to . " 23:59:59'");
}
// If band is set, we only load contacts for that band
@@ -436,13 +436,13 @@ class Contesting_model extends CI_Model {
$binding = [];
$sql = "select distinct COL_BAND band
from " . $this->config->item('table_name') . "
where date(" . $this->config->item('table_name') . ".COL_TIME_ON) >= ?
and date(" . $this->config->item('table_name') . ".COL_TIME_ON) <= ?
where COL_TIME_ON >= ?
and COL_TIME_ON <= ?
and station_id = ? and COL_CONTEST_ID = ?";
//add data to bindings
$binding[] = $from;
$binding[] = $to;
//add data to bindings - convert dates to datetime for index usage
$binding[] = $from . ' 00:00:00';
$binding[] = $to . ' 23:59:59';
$binding[] = $station_id;
$binding[] = $contestid;