posts: fix timeouts for searches using sequential navigation.
Fix certain searches timing out when using sequential navigation (page=b1234). The problem was that the so-called "small search optimization" (AKA: force Postgres to use the tag index for small searches instead a sequential scan) wasn't triggering because the ORDER BY clause for sequential navigation was `posts.id desc`, and we were only checking for `posts.id DESC`.
This commit is contained in:
@@ -64,11 +64,11 @@ module PaginationExtension
|
||||
end
|
||||
|
||||
def paginate_sequential_before(before_id, limit)
|
||||
where("#{table_name}.id < ?", before_id).reorder("#{table_name}.id desc").limit(limit + 1)
|
||||
where("#{table_name}.id < ?", before_id).reorder("#{table_name}.id DESC").limit(limit + 1)
|
||||
end
|
||||
|
||||
def paginate_sequential_after(after_id, limit)
|
||||
where("#{table_name}.id > ?", after_id).reorder("#{table_name}.id asc").limit(limit + 1)
|
||||
where("#{table_name}.id > ?", after_id).reorder("#{table_name}.id ASC").limit(limit + 1)
|
||||
end
|
||||
|
||||
def paginate_numbered(page, limit)
|
||||
|
||||
Reference in New Issue
Block a user