From 894ebcf5e94c917f5e10e5196f74b8055e2b2407 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 21 Mar 2006 08:09:18 +0100 Subject: [PATCH] update_daemon work, remove unneeded indexes, query optimizations --- backend.php | 14 +++++++++----- functions.js | 7 ++++++- functions.php | 18 +++++++++++------- schema/ttrss_schema_pgsql.sql | 13 +++++++------ update_daemon.php | 8 +++++--- viewfeed.js | 7 +++++-- 6 files changed, 43 insertions(+), 24 deletions(-) diff --git a/backend.php b/backend.php index 06e7a4756..39628f58e 100644 --- a/backend.php +++ b/backend.php @@ -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"]; @@ -1490,7 +1490,7 @@ // $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, @@ -1507,7 +1507,11 @@ $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 diff --git a/functions.js b/functions.js index e016d8c8a..376490e08 100644 --- a/functions.js +++ b/functions.js @@ -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; diff --git a/functions.php b/functions.php index dcda35ece..988369c32 100644 --- a/functions.php +++ b/functions.php @@ -1,10 +1,10 @@ diff --git a/schema/ttrss_schema_pgsql.sql b/schema/ttrss_schema_pgsql.sql index a4a711078..82c5506a6 100644 --- a/schema/ttrss_schema_pgsql.sql +++ b/schema/ttrss_schema_pgsql.sql @@ -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, diff --git a/update_daemon.php b/update_daemon.php index cf51bdd3a..8c36fda68 100644 --- a/update_daemon.php +++ b/update_daemon.php @@ -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(); } @@ -71,9 +71,11 @@ // 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(); diff --git a/viewfeed.js b/viewfeed.js index aaeb43985..8ad6c5207 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -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;