diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-03-13 21:10:06 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-03-13 21:10:06 +0100 |
commit | 66f9c09ba502e39ceab72a4bcf98ee90371dc7aa (patch) | |
tree | faf1b63821092f62c50a7ab2ae2765c468433ebd | |
parent | 1c5a4c12137beeaf3c0713272fe90861acd87bf4 (diff) | |
parent | c43ad073e4902471637140dc782733da3b93bfa1 (diff) | |
download | forums-66f9c09ba502e39ceab72a4bcf98ee90371dc7aa.tar forums-66f9c09ba502e39ceab72a4bcf98ee90371dc7aa.tar.gz forums-66f9c09ba502e39ceab72a4bcf98ee90371dc7aa.tar.bz2 forums-66f9c09ba502e39ceab72a4bcf98ee90371dc7aa.tar.xz forums-66f9c09ba502e39ceab72a4bcf98ee90371dc7aa.zip |
Merge pull request #5512 from jasonmarlin/ticket/15941
[ticket/15941] Replace MAX to speed up query in update_post_information
-rw-r--r-- | phpBB/includes/functions_posting.php | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php index c7d691287c..3640f543d9 100644 --- a/phpBB/includes/functions_posting.php +++ b/phpBB/includes/functions_posting.php @@ -202,11 +202,13 @@ function update_post_information($type, $ids, $return_update_sql = false) if (count($ids) == 1) { - $sql = 'SELECT MAX(p.post_id) as last_post_id + $sql = 'SELECT p.post_id as last_post_id FROM ' . POSTS_TABLE . " p $topic_join WHERE " . $db->sql_in_set('p.' . $type . '_id', $ids) . " $topic_condition - AND p.post_visibility = " . ITEM_APPROVED; + AND p.post_visibility = " . ITEM_APPROVED . " + ORDER BY p.post_id DESC"; + $result = $db->sql_query_limit($sql, 1); } else { @@ -216,8 +218,8 @@ function update_post_information($type, $ids, $return_update_sql = false) $topic_condition AND p.post_visibility = " . ITEM_APPROVED . " GROUP BY p.{$type}_id"; + $result = $db->sql_query($sql); } - $result = $db->sql_query($sql); $last_post_ids = array(); while ($row = $db->sql_fetchrow($result)) |