]> git.wh0rd.org Git - tt-rss.git/commitdiff
Modify query to avoid a full table scan on MySQL
authortmo-github <github@yuit.net>
Thu, 27 Nov 2014 19:04:24 +0000 (20:04 +0100)
committertmo-github <github@yuit.net>
Thu, 27 Nov 2014 19:04:24 +0000 (20:04 +0100)
include/functions2.php

index 866c92ec90b0a3931d753c33ebbdc7b4a70be86e..29594076c1c6baaac8fc87560a41652863b269c8 100644 (file)
        }
 
        function getLastArticleId() {
-               $result = db_query("SELECT MAX(ref_id) AS id FROM ttrss_user_entries
-                       WHERE owner_uid = " . $_SESSION["uid"]);
+               $result = db_query("SELECT ref_id AS id FROM ttrss_user_entries
+                       WHERE owner_uid = " . $_SESSION["uid"] . " ORDER BY ref_id DESC LIMIT 1");
 
                if (db_num_rows($result) == 1) {
                        return db_fetch_result($result, 0, "id");