From b8de6338bff864ec9a7837e81aeede42ab9d3d21 Mon Sep 17 00:00:00 2001 From: Martin Ambrus Date: Mon, 23 Oct 2017 00:33:13 +0200 Subject: [PATCH] refactor: SQL optimizations --- Admin/Templates/resetServer.php | 6 +- GameEngine/Automation.php | 2 +- GameEngine/Database.php | 2 +- install/data/sql.sql | 246 +++++++++++++++++--------------- sql_updates.txt | 31 ++++ todo.txt | 8 +- 6 files changed, 175 insertions(+), 120 deletions(-) diff --git a/Admin/Templates/resetServer.php b/Admin/Templates/resetServer.php index 75fa3475..bcbaa444 100644 --- a/Admin/Templates/resetServer.php +++ b/Admin/Templates/resetServer.php @@ -83,9 +83,9 @@ $passw=password_hash("12345", PASSWORD_BCRYPT,['cost' => 12]); mysqli_query($GLOBALS["link"], "TRUNCATE TABLE ".TB_PREFIX."users"); mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."users (id, username, password, email, tribe, access, gold, gender, birthday, location, desc1, desc2, plus, b1, b2, b3, b4, sit1, sit2, alliance, sessid, act, timestamp, ap, apall, dp, dpall, protect, quest, gpack, cp, lastupdate, RR, Rc, ok) VALUES (5, 'Multihunter', '".$passw."', 'multihunter@travianx.mail', 0, 9, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(1, 'Support', '', 'support@travianx.mail', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(2, 'Nature', '', 'support@travianx.mail', 4, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(4, 'Taskmaster', '', 'support@travianx.mail', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0)"); +(1, 'Support', '', 'support@travianz.game', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(2, 'Nature', '', 'nature@travianz.game', 4, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(4, 'Taskmaster', '', 'taskmaster@travianz.game', 0, 8, 0, 0, '0000-00-00', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0)"); mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."units (vref) VALUES ($uid)"); mysqli_query($GLOBALS["link"], "INSERT INTO ".TB_PREFIX."tdata (vref) VALUES ($uid)"); diff --git a/GameEngine/Automation.php b/GameEngine/Automation.php index 9e39fcb6..158dfa40 100755 --- a/GameEngine/Automation.php +++ b/GameEngine/Automation.php @@ -5298,7 +5298,7 @@ $wallimg = "= 86400"; + $q = "SELECT * FROM " . TB_PREFIX . "artefacts where type = 8 and active = 1 and lastupdate <= ".($time - 86400); $array = $database->query_return($q); foreach($array as $artefact) { $kind = rand(1,7); diff --git a/GameEngine/Database.php b/GameEngine/Database.php index 7061ae46..18125650 100755 --- a/GameEngine/Database.php +++ b/GameEngine/Database.php @@ -3977,7 +3977,7 @@ class MYSQLi_DB { function getFoolArtefactInfo($type,$vid,$uid) { list($type,$vid,$uid) = $this->escape_input((int) $type,(int) $vid,(int) $uid); - $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND type = 8 AND kind = $type OR owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type"; + $q = "SELECT * FROM " . TB_PREFIX . "artefacts WHERE vref = $vid AND ((type = 8 AND kind = $type) OR (owner = $uid AND size > 1 AND active = 1 AND type = 8 AND kind = $type))"; $result = mysqli_query($this->dblink,$q); return $this->mysqli_fetch_all($result); } diff --git a/install/data/sql.sql b/install/data/sql.sql index 28016fd4..766e1471 100644 --- a/install/data/sql.sql +++ b/install/data/sql.sql @@ -102,16 +102,18 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%abdata` ( CREATE TABLE IF NOT EXISTS `%PREFIX%activate` ( `id` int(255) NOT NULL AUTO_INCREMENT, - `username` varchar(100) NULL, - `password` varchar(100) NULL, - `email` text NULL, - `tribe` tinyint(1) NULL, - `access` tinyint(1) NULL DEFAULT '1', - `act` varchar(10) NULL, - `timestamp` int(11) NULL DEFAULT '0', - `location` text NULL, - `act2` varchar(10) NULL, - PRIMARY KEY (`id`) + `username` varchar(100) NOT NULL, + `password` varchar(100) DEFAULT NULL, + `email` varchar(255) NOT NULL, + `tribe` tinyint(1) DEFAULT NULL, + `access` tinyint(1) DEFAULT '1', + `act` varchar(10) DEFAULT NULL, + `timestamp` int(11) DEFAULT '0', + `location` text, + `act2` varchar(10) DEFAULT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `username` (`username`), + UNIQUE KEY `email` (`email`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -128,7 +130,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%activate` ( CREATE TABLE IF NOT EXISTS `%PREFIX%active` ( `username` varchar(100) NOT NULL, `timestamp` int(11) NULL, - PRIMARY KEY (`username`) + PRIMARY KEY (`username`), + KEY `timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -196,8 +199,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%artefacts` ( `effect2` tinyint(2) NULL DEFAULT '0', `lastupdate` int(11) NULL DEFAULT '0', PRIMARY KEY (`id`), - KEY `vref-type` (`vref`,`type`), - KEY `owner-active` (`owner`,`active`) + KEY `owner-active` (`owner`,`active`), + KEY `vref-type-kind` (`vref`,`type`,`kind`) USING BTREE, + KEY `active-type-lastupdate` (`active`,`type`,`lastupdate`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -460,7 +464,8 @@ INSERT INTO `%PREFIX%config` VALUES (0); CREATE TABLE IF NOT EXISTS `%PREFIX%deleting` ( `uid` int(11) NOT NULL, `timestamp` int(11) NULL, - PRIMARY KEY (`uid`) + PRIMARY KEY (`uid`), + KEY `timestamp` (`timestamp`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1058,7 +1063,8 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%movement` ( `crop` int(11) DEFAULT NULL, PRIMARY KEY (`moveid`), KEY `ref` (`ref`), - KEY `from-proc-sort_type` (`from`,`proc`,`sort_type`) + KEY `from-proc-sort_type` (`from`,`proc`,`sort_type`), + KEY `proc-sort_type-endtime` (`proc`,`sort_type`,`endtime`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- @@ -1119,7 +1125,12 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%odata` ( `high` tinyint(1) NULL, PRIMARY KEY (`wref`), KEY `lastupdated2` (`lastupdated2`) USING BTREE, - KEY `conqured` (`conqured`) + KEY `conqured` (`conqured`), + KEY `wood` (`wood`), + KEY `iron` (`iron`), + KEY `clay` (`clay`), + KEY `crop` (`crop`), + KEY `loyalty` (`loyalty`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- @@ -1458,100 +1469,101 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%units` ( CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( `id` int(11) NOT NULL AUTO_INCREMENT, - `username` varchar(100) NULL, - `password` varchar(100) NULL, - `email` text NULL, - `tribe` tinyint(1) NULL, - `access` tinyint(1) NULL DEFAULT '1', - `gold` int(9) NULL DEFAULT '0', - `gender` tinyint(1) NULL DEFAULT '0', - `birthday` date NULL DEFAULT '1970-01-01', - `location` text NULL, - `desc1` text NULL, - `desc2` text NULL, - `plus` int(11) NULL DEFAULT '0', - `goldclub` int(11) NULL DEFAULT '0', - `b1` int(11) NULL DEFAULT '0', - `b2` int(11) NULL DEFAULT '0', - `b3` int(11) NULL DEFAULT '0', - `b4` int(11) NULL DEFAULT '0', - `sit1` int(11) NULL DEFAULT '0', - `sit2` int(11) NULL DEFAULT '0', - `alliance` int(11) NULL DEFAULT '0', - `sessid` varchar(100) NULL, - `act` varchar(10) NULL, - `timestamp` int(11) NULL DEFAULT '0', - `ap` int(11) NULL DEFAULT '0', - `apall` int(11) NULL DEFAULT '0', - `dp` int(11) NULL DEFAULT '0', - `dpall` int(11) NULL DEFAULT '0', - `protect` int(11) NULL, - `quest` tinyint(2) NULL, - `quest_time` int(11) NULL, - `gpack` varchar(255) NULL DEFAULT 'gpack/travian_default/', - `cp` float(14,5) NULL DEFAULT '1', - `lastupdate` int(11) NULL, - `RR` int(255) NULL DEFAULT '0', - `Rc` int(255) NULL DEFAULT '0', - `ok` tinyint(1) NULL DEFAULT '0', - `clp` bigint(255) NULL DEFAULT '0', - `oldrank` bigint(255) NULL DEFAULT '0', - `regtime` int(11) NULL DEFAULT '0', - `invited` int(11) NULL DEFAULT '0', - `friend0` int(11) NULL DEFAULT '0', - `friend1` int(11) NULL DEFAULT '0', - `friend2` int(11) NULL DEFAULT '0', - `friend3` int(11) NULL DEFAULT '0', - `friend4` int(11) NULL DEFAULT '0', - `friend5` int(11) NULL DEFAULT '0', - `friend6` int(11) NULL DEFAULT '0', - `friend7` int(11) NULL DEFAULT '0', - `friend8` int(11) NULL DEFAULT '0', - `friend9` int(11) NULL DEFAULT '0', - `friend10` int(11) NULL DEFAULT '0', - `friend11` int(11) NULL DEFAULT '0', - `friend12` int(11) NULL DEFAULT '0', - `friend13` int(11) NULL DEFAULT '0', - `friend14` int(11) NULL DEFAULT '0', - `friend15` int(11) NULL DEFAULT '0', - `friend16` int(11) NULL DEFAULT '0', - `friend17` int(11) NULL DEFAULT '0', - `friend18` int(11) NULL DEFAULT '0', - `friend19` int(11) NULL DEFAULT '0', - `friend0wait` int(11) NULL DEFAULT '0', - `friend1wait` int(11) NULL DEFAULT '0', - `friend2wait` int(11) NULL DEFAULT '0', - `friend3wait` int(11) NULL DEFAULT '0', - `friend4wait` int(11) NULL DEFAULT '0', - `friend5wait` int(11) NULL DEFAULT '0', - `friend6wait` int(11) NULL DEFAULT '0', - `friend7wait` int(11) NULL DEFAULT '0', - `friend8wait` int(11) NULL DEFAULT '0', - `friend9wait` int(11) NULL DEFAULT '0', - `friend10wait` int(11) NULL DEFAULT '0', - `friend11wait` int(11) NULL DEFAULT '0', - `friend12wait` int(11) NULL DEFAULT '0', - `friend13wait` int(11) NULL DEFAULT '0', - `friend14wait` int(11) NULL DEFAULT '0', - `friend15wait` int(11) NULL DEFAULT '0', - `friend16wait` int(11) NULL DEFAULT '0', - `friend17wait` int(11) NULL DEFAULT '0', - `friend18wait` int(11) NULL DEFAULT '0', - `friend19wait` int(11) NULL DEFAULT '0', - `maxevasion` mediumint(3) NULL DEFAULT '0', - `village_select` bigint(20) DEFAULT NULL, - `vac_time` varchar(255) NULL DEFAULT '0', - `vac_mode` int(2) NULL DEFAULT '0', - `vactwoweeks` varchar(255) NULL DEFAULT '0', - `is_bcrypt` tinyint(1) NOT NULL DEFAULT '0', - PRIMARY KEY (`id`), - KEY `invited` (`invited`), - KEY `lastupdate` (`lastupdate`), - KEY `alliance` (`alliance`), - KEY `username` (`username`(25)) USING BTREE, - KEY `tribe` (`tribe`), - KEY `timestamp` (`timestamp`), - KEY `timestamp-tribe` (`timestamp`,`tribe`) + `username` varchar(100) DEFAULT NULL, + `password` varchar(100) DEFAULT NULL, + `email` varchar(255) DEFAULT NULL, + `tribe` tinyint(1) DEFAULT NULL, + `access` tinyint(1) DEFAULT '1', + `gold` int(9) DEFAULT '0', + `gender` tinyint(1) DEFAULT '0', + `birthday` date DEFAULT '1970-01-01', + `location` text, + `desc1` text, + `desc2` text, + `plus` int(11) DEFAULT '0', + `goldclub` int(11) DEFAULT '0', + `b1` int(11) DEFAULT '0', + `b2` int(11) DEFAULT '0', + `b3` int(11) DEFAULT '0', + `b4` int(11) DEFAULT '0', + `sit1` int(11) DEFAULT '0', + `sit2` int(11) DEFAULT '0', + `alliance` int(11) DEFAULT '0', + `sessid` varchar(100) DEFAULT NULL, + `act` varchar(10) DEFAULT NULL, + `timestamp` int(11) DEFAULT '0', + `ap` int(11) DEFAULT '0', + `apall` int(11) DEFAULT '0', + `dp` int(11) DEFAULT '0', + `dpall` int(11) DEFAULT '0', + `protect` int(11) DEFAULT NULL, + `quest` tinyint(2) DEFAULT NULL, + `quest_time` int(11) DEFAULT NULL, + `gpack` varchar(255) DEFAULT 'gpack/travian_default/', + `cp` float(14,5) DEFAULT '1.00000', + `lastupdate` int(11) DEFAULT NULL, + `RR` int(255) DEFAULT '0', + `Rc` int(255) DEFAULT '0', + `ok` tinyint(1) DEFAULT '0', + `clp` bigint(255) DEFAULT '0', + `oldrank` bigint(255) DEFAULT '0', + `regtime` int(11) DEFAULT '0', + `invited` int(11) DEFAULT '0', + `friend0` int(11) DEFAULT '0', + `friend1` int(11) DEFAULT '0', + `friend2` int(11) DEFAULT '0', + `friend3` int(11) DEFAULT '0', + `friend4` int(11) DEFAULT '0', + `friend5` int(11) DEFAULT '0', + `friend6` int(11) DEFAULT '0', + `friend7` int(11) DEFAULT '0', + `friend8` int(11) DEFAULT '0', + `friend9` int(11) DEFAULT '0', + `friend10` int(11) DEFAULT '0', + `friend11` int(11) DEFAULT '0', + `friend12` int(11) DEFAULT '0', + `friend13` int(11) DEFAULT '0', + `friend14` int(11) DEFAULT '0', + `friend15` int(11) DEFAULT '0', + `friend16` int(11) DEFAULT '0', + `friend17` int(11) DEFAULT '0', + `friend18` int(11) DEFAULT '0', + `friend19` int(11) DEFAULT '0', + `friend0wait` int(11) DEFAULT '0', + `friend1wait` int(11) DEFAULT '0', + `friend2wait` int(11) DEFAULT '0', + `friend3wait` int(11) DEFAULT '0', + `friend4wait` int(11) DEFAULT '0', + `friend5wait` int(11) DEFAULT '0', + `friend6wait` int(11) DEFAULT '0', + `friend7wait` int(11) DEFAULT '0', + `friend8wait` int(11) DEFAULT '0', + `friend9wait` int(11) DEFAULT '0', + `friend10wait` int(11) DEFAULT '0', + `friend11wait` int(11) DEFAULT '0', + `friend12wait` int(11) DEFAULT '0', + `friend13wait` int(11) DEFAULT '0', + `friend14wait` int(11) DEFAULT '0', + `friend15wait` int(11) DEFAULT '0', + `friend16wait` int(11) DEFAULT '0', + `friend17wait` int(11) DEFAULT '0', + `friend18wait` int(11) DEFAULT '0', + `friend19wait` int(11) DEFAULT '0', + `maxevasion` mediumint(3) DEFAULT '0', + `village_select` bigint(20) DEFAULT NULL, + `vac_time` varchar(255) DEFAULT '0', + `vac_mode` int(2) DEFAULT '0', + `vactwoweeks` varchar(255) DEFAULT '0', + `is_bcrypt` tinyint(1) NOT NULL DEFAULT '0', + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`), + UNIQUE KEY `username` (`username`), + KEY `invited` (`invited`), + KEY `lastupdate` (`lastupdate`), + KEY `alliance` (`alliance`), + KEY `tribe` (`tribe`), + KEY `timestamp-tribe` (`timestamp`,`tribe`), + KEY `access` (`access`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; -- @@ -1560,9 +1572,9 @@ CREATE TABLE IF NOT EXISTS `%PREFIX%users` ( INSERT INTO `%PREFIX%users` (`id`, `username`, `password`, `email`, `tribe`, `access`, `gold`, `gender`, `birthday`, `location`, `desc1`, `desc2`, `plus`, `b1`, `b2`, `b3`, `b4`, `sit1`, `sit2`, `alliance`, `sessid`, `act`, `timestamp`, `ap`, `apall`, `dp`, `dpall`, `protect`, `quest`, `gpack`, `cp`, `lastupdate`, `RR`, `Rc`, `ok`) VALUES (5, 'Multihunter', '', 'multihunter@travianx.mail', 0, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(1, 'Support', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(2, 'Nature', '4262cc190152adfc1a3fcf32af6aa430', 'support@travianx.mail', 4, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), -(4, 'Taskmaster', '', 'support@travianx.mail', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0); +(1, 'Support', '', 'support@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(2, 'Nature', '4262cc190152adfc1a3fcf32af6aa430', 'nature@travianz.game', 4, 9, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0), +(4, 'Taskmaster', '', 'taskmaster@travianz.game', 0, 8, 0, 0, '1970-01-01', '', '', '', 0, 0, 0, 0, 0, 0, 0, 0, '', '', 0, 0, 0, 0, 0, 0, 0, 'gpack/travian_default/', 1, 0, 0, 0, 0); -- -------------------------------------------------------- @@ -1600,7 +1612,13 @@ PRIMARY KEY (`wref`), KEY `owner-capital-pop` (`owner`,`capital`,`pop`), KEY `maxstore` (`maxstore`), KEY `maxcrop` (`maxcrop`), -KEY `celebration` (`celebration`) +KEY `celebration` (`celebration`), +KEY `wood` (`wood`), +KEY `clay` (`clay`), +KEY `iron` (`iron`), +KEY `crop` (`crop`), +KEY `starv` (`starv`), +KEY `loyalty` (`loyalty`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; -- diff --git a/sql_updates.txt b/sql_updates.txt index 8c269f62..c94d833b 100644 --- a/sql_updates.txt +++ b/sql_updates.txt @@ -1,11 +1,42 @@ -- 22.10.2017 -> SQL optimizations ALTER TABLE `s1_users` ADD INDEX(`tribe`); ALTER TABLE `s1_users` ADD INDEX `timestamp-tribe` (`timestamp`, `tribe`); +ALTER TABLE `s1_users` DROP INDEX `username`; +ALTER TABLE `s1_users` ADD UNIQUE `username` (`username`); +ALTER TABLE `s1_activate` CHANGE `username` `username` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `s1_activate` ADD UNIQUE `username` (`username`); +ALTER TABLE `s1_activate` CHANGE `email` `email` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL; +ALTER TABLE `s1_activate` ADD UNIQUE(`email`); +ALTER TABLE `s1_users` CHANGE `email` `email` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL; +-- YOU MAY NOT NEED THESE IF YOUR EMAILS FOR THESE 3 ACCOUNTS ARE ALREADY DIFFERENT FROM ONE ANOTHER +UPDATE `s1_users` SET `email` = 'support@travianz.game' WHERE `s1_users`.`id` = 1; +UPDATE `s1_users` SET `email` = 'nature@travianz.game' WHERE `s1_users`.`id` = 2; +UPDATE `s1_users` SET `email` = 'taskmaster@travianz.game' WHERE `s1_users`.`id` = 4; +-- END OF "YOU MAY NOT NEED THESE" +ALTER TABLE `s1_users` ADD UNIQUE `email` (`email`); +ALTER TABLE `s1_users` ADD INDEX(`access`); +ALTER TABLE `s1_active` ADD INDEX(`timestamp`); +ALTER TABLE `s1_odata` ADD INDEX(`clay`); +ALTER TABLE `s1_odata` ADD INDEX(`crop`); +ALTER TABLE `s1_odata` ADD INDEX(`iron`); +ALTER TABLE `s1_odata` ADD INDEX(`wood`); +ALTER TABLE `s1_vdata` ADD INDEX(`crop`); +ALTER TABLE `s1_vdata` ADD INDEX(`iron`); +ALTER TABLE `s1_vdata` ADD INDEX(`clay`); +ALTER TABLE `s1_vdata` ADD INDEX(`wood`); +ALTER TABLE `s1_deleting` ADD INDEX(`timestamp`); +ALTER TABLE `s1_movement` ADD INDEX `proc-sort_type-endtime` (`proc`, `sort_type`, `endtime`); +ALTER TABLE `s1_vdata` ADD INDEX(`starv`); +ALTER TABLE `s1_vdata` ADD INDEX(`loyalty`); +ALTER TABLE `s1_odata` ADD INDEX(`loyalty`); +ALTER TABLE `s1_artefacts` ADD INDEX `active-type-lastupdate` (`active`, `type`, `lastupdate`); + -- 22.10.2017 -> forum topics table and indexe changes ALTER TABLE `s1_forum_post` CHANGE `topic` `topic` INT NULL DEFAULT NULL; ALTER TABLE `s1_forum_post` CHANGE `owner` `owner` INT NULL DEFAULT NULL; ALTER TABLE `travian`.`s1_forum_post` ADD INDEX `topic-owner` (`topic`, `owner`); + -- 20.10.2017 -> changing MD5 for bcrypt password hashing algo ALTER TABLE `s1_users` ADD `is_bcrypt` TINYINT(1) NOT NULL DEFAULT '0' AFTER `vactwoweeks`; \ No newline at end of file diff --git a/todo.txt b/todo.txt index c0822487..e6fa78dc 100644 --- a/todo.txt +++ b/todo.txt @@ -5,4 +5,10 @@ - finish parts in Admin that are unfinished (mostly delete -X- buttons and Alliance settings) - add batching logic to mehods which get called too frequently and multiple times (example - Message::sendMessage() now that is sends messages for each forum post) - include past raids in the farm list that were not in the farm list itself but are actually manual past attacks - will need DB update for the attacks table to include targets (now only holds attacker) -- add PayPal listener to verify gold transactions imediatelly \ No newline at end of file +- add PayPal listener to verify gold transactions imediatelly +- check the following queries for performing stuff on DB rather than in PHP: + "SELECT * FROM s1_vdata WHERE wood > maxstore OR clay > maxstore OR iron > maxstore OR crop > maxcrop" + "SELECT * FROM s1_odata WHERE maxstore < 800 OR maxcrop < 800" + "SELECT * FROM s1_vdata WHERE wood < 0 OR clay < 0 OR iron < 0 OR crop < 0" +- try to find and fix this (it's probably automation but has came up with a new registration, first login): + "UPDATE s1_units set hero = hero - WHERE vref = 38801" \ No newline at end of file