]> git.mxchange.org Git - friendica.git/commitdiff
Merge pull request #594 from fermionic/20130127-add-event-id-index
authorfriendica <info@friendica.com>
Mon, 28 Jan 2013 03:11:58 +0000 (19:11 -0800)
committerfriendica <info@friendica.com>
Mon, 28 Jan 2013 03:11:58 +0000 (19:11 -0800)
add event-id index to prevent large CPU loads when visiting the events page

boot.php
database.sql
update.php

index 9f8de4293a2d1348bfa8409503cd113e2093bc63..3064b817d27028175136f9915e26e5b531ffbfab 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -14,7 +14,7 @@ require_once('include/features.php');
 define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_VERSION',      '3.1.1601' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1158      );
+define ( 'DB_UPDATE_VERSION',      1159      );
 
 define ( 'EOL',                    "<br />\r\n"     );
 define ( 'ATOM_TIME',              'Y-m-d\TH:i:s\Z' );
index 28a7c931e77b97f3360313b06f9209411480ca71..6a4782fb89cccf31ba98d38b8163a00a05356ec7 100644 (file)
@@ -589,6 +589,7 @@ CREATE TABLE IF NOT EXISTS `item` (
   KEY `uid_commented` (`uid`, `commented`),
   KEY `uid_created` (`uid`, `created`),
   KEY `uid_unseen` (`uid`, `unseen`),
+  KEY `event_id` (`event-id`),
   FULLTEXT KEY `title` (`title`),
   FULLTEXT KEY `body` (`body`),
   FULLTEXT KEY `allow_cid` (`allow_cid`),
index 1bea71f4d7ded1d63e7692200439115f88d709a0..b70e7b8ce198d0ad907896a101e7a252fa37e681 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define( 'UPDATE_VERSION' , 1158 );
+define( 'UPDATE_VERSION' , 1159 );
 
 /**
  *
@@ -1386,3 +1386,19 @@ function update_1157() {
        return UPDATE_FAILED;
 }
 
+function update_1158() {
+       set_config('system', 'maintenance', 1);
+
+       // Wait for 15 seconds for current requests to
+       // clear before locking up the database
+       sleep(15);
+
+       $r = q("CREATE INDEX event_id ON item(`event-id`)");
+       set_config('system', 'maintenance', 0);
+
+       if($r)
+               return UPDATE_SUCCESS;
+
+       return UPDATE_FAILED;
+}
+