]> git.wh0rd.org Git - tt-rss.git/commitdiff
update_daemon work, remove unneeded indexes, query optimizations
authorAndrew Dolgov <fox@madoka.spb.ru>
Tue, 21 Mar 2006 07:09:18 +0000 (08:09 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Tue, 21 Mar 2006 07:09:18 +0000 (08:09 +0100)
backend.php
functions.js
functions.php
schema/ttrss_schema_pgsql.sql
update_daemon.php
viewfeed.js

index 06e7a47560a7a7735e93526699164e6d0e578b1b..39628f58e8214d62c76a93fa49f6b62ba4524be0 100644 (file)
@@ -5,13 +5,13 @@
        header("Pragma: no-cache");
        header("Expires: -1");
        
-       if ($_GET["debug"]) {
+/*     if ($_GET["debug"]) {
                define('DEFAULT_ERROR_LEVEL', E_ALL);
        } else {
                define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
        }
-
-       error_reporting(DEFAULT_ERROR_LEVEL);
+       
+       error_reporting(DEFAULT_ERROR_LEVEL); */
 
        $op = $_REQUEST["op"];
 
 //                             $content_query_part = "";
 //                     }
 
-                       $result = db_query($link, "SELECT 
+                       $query = "SELECT 
                                        ttrss_entries.id,ttrss_entries.title,
                                        SUBSTRING(updated,1,16) as updated,
                                        unread,feed_id,marked,link,last_read,
                                $search_query_part
                                $view_query_part
                                $query_strategy_part ORDER BY $order_by
-                               $limit_query_part");
+                               $limit_query_part";
+                               
+                       $result = db_query($link, $query);
+
+                       if ($_GET["debug"]) print $query;
 
                } else {
                        // browsing by tag
index e016d8c8a603fd7217c6452a73d1a106251b6eea..376490e0851ad869fdb0de7c99ee777d4077425f 100644 (file)
@@ -471,7 +471,12 @@ function all_counters_callback() {
                                notify("[all_counters_callback] backend did not return valid XML");
                                return;
                        }
-       
+
+                       if (!parent.frames["feeds-frame"]) {
+                               notify("[all_counters_callback] no parent feeds-frame");
+                               return;
+                       }
+
                        var reply = xmlhttp_rpc.responseXML.firstChild;
                        var f_document = parent.frames["feeds-frame"].document;
 
index dcda35ece0d9f6408c08b6870cb6c377d1b64b6b..988369c32bc0dc61b175cfcf6ec48c670c8b7f95 100644 (file)
@@ -1,10 +1,10 @@
 <?
 
-       if ($_GET["debug"]) {
+/*     if ($_GET["debug"]) {
                define('DEFAULT_ERROR_LEVEL', E_ALL);
        } else {
                define('DEFAULT_ERROR_LEVEL', E_ERROR | E_WARNING | E_PARSE);
-       }
+       } */
 
        require_once 'config.php';
        require_once 'db-prefs.php';
 
        function global_purge_old_posts($link, $do_output = false, $limit = false) {
 
-               if (DB_TYPE == "mysql") {
-                       $random_qpart = "RAND()";
-               } else {
-                       $random_qpart = "RANDOM()";
-               }
+               $random_qpart = sql_random_function();
 
                if ($limit) {
                        $limit_qpart = "LIMIT $limit";
                }
        }
 
+       function sql_random_function() {
+               if (DB_TYPE == "mysql") {
+                       return "RAND()";
+               } else {
+                       return "RANDOM()";
+               }
+       }
+
 ?>
index a4a711078e22d069c968d1a09e4c5498688a228d..82c5506a69df4b9b316fca466ed879d7b29415ce 100644 (file)
@@ -82,8 +82,8 @@ create table ttrss_entries (id serial not null primary key,
        author varchar(250) not null default '');
 
 create index ttrss_entries_guid_index on ttrss_entries(guid);
-create index ttrss_entries_title_index on ttrss_entries(title);
-create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
+-- create index ttrss_entries_title_index on ttrss_entries(title);
+-- create index ttrss_entries_date_entered_index on ttrss_entries(date_entered);
 
 create table ttrss_user_entries (
        int_id serial not null primary key,
@@ -94,9 +94,10 @@ create table ttrss_user_entries (
        last_read timestamp,
        unread boolean not null default true);
 
-create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
-create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
+-- create index ttrss_user_entries_feed_id_index on ttrss_user_entries(feed_id);
+-- create index ttrss_user_entries_owner_uid_index on ttrss_user_entries(owner_uid);
 create index ttrss_user_entries_ref_id_index on ttrss_user_entries(ref_id);
+create index ttrss_user_entries_feed_id on ttrss_user_entries(feed_id);
 
 create table ttrss_entry_comments (id serial not null primary key,
        ref_id integer not null references ttrss_entries(id) ON DELETE CASCADE,
@@ -105,7 +106,7 @@ create table ttrss_entry_comments (id serial not null primary key,
        date_entered timestamp not null);
        
 create index ttrss_entry_comments_ref_id_index on ttrss_entry_comments(ref_id);
-create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
+-- create index ttrss_entry_comments_owner_uid_index on ttrss_entry_comments(owner_uid);
 
 create table ttrss_filter_types (id integer not null primary key, 
        name varchar(120) unique not null, 
@@ -229,7 +230,7 @@ create table ttrss_user_prefs (
        value text not null);
 
 create index ttrss_user_prefs_owner_uid_index on ttrss_user_prefs(owner_uid);
-create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
+-- create index ttrss_user_prefs_value_index on ttrss_user_prefs(value);
 
 create table ttrss_scheduled_updates (id serial not null primary key,
        owner_uid integer not null references ttrss_users(id) ON DELETE CASCADE,
index cf51bdd3abfe090ff28a76e438bffd7bc458fa37..8c36fda6831c755de271d99eb29e40c6af81443b 100644 (file)
@@ -55,8 +55,8 @@
        while (true) {
 
                if (time() - $last_purge > PURGE_INTERVAL) {
-                       print "Purging old posts...\n";
-                       global_purge_old_posts($link, true);
+                       print "Purging old posts (random 30 feeds)...\n";
+                       global_purge_old_posts($link, true, 30);
                        $last_purge = time();
                }
 
        
                // Process all other feeds using last_updated and interval parameters
 
+               $random_qpart = sql_random_function();
+
                $result = db_query($link, "SELECT feed_url,id,owner_uid,
                        SUBSTRING(last_updated,1,19) AS last_updated,
-                       update_interval FROM ttrss_feeds ORDER BY last_updated DESC");
+                       update_interval FROM ttrss_feeds ORDER BY $random_qpart DESC");
 
                $user_prefs_cache = array();
 
index aaeb4398587fd3d1dd59b1aa7a92b71cdc42071b..8ad6c52074895ba5079f860921cc42a66a7648f0 100644 (file)
@@ -178,7 +178,7 @@ function localHotkeyHandler(keycode) {
        if (keycode == 82) { // r
                return parent.scheduleFeedUpdate(true);
        }
-
+       
        var f_doc = parent.frames["feeds-frame"].document;
        var feedlist = f_doc.getElementById('feedList');
 
@@ -361,7 +361,10 @@ function catchupPage() {
 function init() {
        if (arguments.callee.done) return;
        arguments.callee.done = true;           
-       document.onkeydown = hotkey_handler;
+
+       if (parent.frames["feeds-frame"]) {
+               document.onkeydown = hotkey_handler;
+       }
 
        var hw = document.getElementById("headlinesList").scrollHeight;
        var pw = parent.document.getElementById("headlines").scrollHeight;