]> git.wh0rd.org Git - tt-rss.git/commitdiff
Performance breakthrough
authorGregThib <GregThib@users.noreply.github.com>
Mon, 13 Jul 2015 10:03:50 +0000 (12:03 +0200)
committerGregThib <GregThib@users.noreply.github.com>
Mon, 13 Jul 2015 10:03:50 +0000 (12:03 +0200)
Improvement in the Purge method for huge performance increase.
"WHERE ref_id IS NOT NULL" is needed by pgsql, not necessarily by mysql.
This is a more standard way to make deletions based on propagation (from ttrss_user_entries) with 1-to-N relations.

include/functions.php

index 22179e1a4c74f59598fba6b753bef8573cc2ad7d..a57c0947809adff86ed265eccdf106074605fe3b 100644 (file)
 
                // purge orphaned posts in main content table
                $result = db_query("DELETE FROM ttrss_entries WHERE
-                       (SELECT COUNT(int_id) FROM ttrss_user_entries WHERE ref_id = id) = 0");
-
+                       id NOT IN (SELECT ref_id FROM ttrss_user_entries WHERE ref_id IS NOT NULL)");
                if ($do_output) {
                        $rows = db_affected_rows($result);
                        _debug("Purged $rows orphaned posts.");