From: tmo-github Date: Thu, 27 Nov 2014 19:04:24 +0000 (+0100) Subject: Modify query to avoid a full table scan on MySQL X-Git-Tag: 1.15~7^2^2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=8458a312aecb64d651c28a14ea4a0f50cf1a58ec;p=tt-rss.git Modify query to avoid a full table scan on MySQL --- diff --git a/include/functions2.php b/include/functions2.php index 866c92ec..29594076 100644 --- a/include/functions2.php +++ b/include/functions2.php @@ -1975,8 +1975,8 @@ } 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");