} // END - if
// We only need the very last attempt to get!
- $result = runCrackerTrackerSql("SELECT * FROM `ctracker_data` WHERE `remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' OR `proxy_addr`='" . getenv('REMOTE_ADDR') . "' ORDER BY `last_attempt` DESC LIMIT 1", __FUNCTION__, __LINE__);
+ $result = runCrackerTrackerSql("SELECT SQL_SMALL_RESULT COUNT(`id`) AS `cnt` FROM `ctracker_data` USE INDEX (`remote_proxy_last`) WHERE `remote_addr`='" . determineCrackerTrackerRealRemoteAddress() . "' OR `proxy_addr`='" . getenv('REMOTE_ADDR') . "' ORDER BY `last_attempt` DESC LIMIT 1", __FUNCTION__, __LINE__);
- // Do we have entries?
- $found = (mysql_num_rows($result) == 1);
+ // Get row count
+ list($rows) = mysql_fetch_row($result);
+
+ // Is there one entry?
+ $found = ($rows > 0);
// And again?
if ($found === TRUE) {
`ctracker_ticket_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
`ctracker_data_id` BIGINT(20) UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY ( `ctracker_ticket_data_id` ),
-UNIQUE KEY `ctracker_ticket_data` ( `ctracker_ticket_id`,`ctracker_data_id` ),
+UNIQUE KEY `ctracker_ticket_data` ( `ctracker_ticket_id`, `ctracker_data_id` ),
INDEX ( `ctracker_data_id` ),
FOREIGN KEY ( `ctracker_ticket_id` ) REFERENCES `' . $GLOBALS['ctracker_dbname'] . '`.`ctracker_ticket` (
`ctracker_ticket`
'ALTER TABLE `ctracker_data` ADD `proxy_addr` VARCHAR(15) NULL DEFAULT NULL',
'ALTER TABLE `ctracker_ticket` ADD `ctracker_ticket_proxy_addr` VARCHAR(15) NULL DEFAULT NULL',
),
+
+ // Better key for always repeating query
+ 3 => array(
+ 'ALTER TABLE `ctracker`.`ctracker_data` ADD INDEX `remote_proxy_last` ( `remote_addr`, `proxy_addr`, `last_attempt` DESC )',
+ ),
);
}