sql - fetch_catalog needs ORDER BY bump time after all those operations
This commit is contained in:
parent
e83df86725
commit
8a10ce4798
|
@ -588,7 +588,13 @@ grouped AS (
|
|||
$$;
|
||||
|
||||
|
||||
SELECT * FROM posts WHERE body_search_index @@ websearch_to_tsquery('english', 'TRUE CHRISTIAN');
|
||||
SELECT * FROM posts WHERE body_search_index @@ websearch_to_tsquery('english', 'holocaust');
|
||||
SELECT *,
|
||||
ts_rank(body_search_index, websearch_to_tsquery('english', 'holocaust')) AS relevance
|
||||
FROM posts
|
||||
WHERE body_search_index @@ websearch_to_tsquery('english', 'holocaust')
|
||||
ORDER BY relevance DESC;
|
||||
|
||||
SELECT to_tsvector('english', body) FROM posts WHERE board_post_id = 476524;
|
||||
SELECT (setweight(to_tsvector('english', COALESCE(subject, '')), 'A') ||
|
||||
setweight(to_tsvector('english', COALESCE(name, '')), 'B') ||
|
||||
|
|
|
@ -140,7 +140,9 @@ RETURNS TABLE (
|
|||
post_id bigint,
|
||||
board_post_id bigint,
|
||||
creation_time timestamptz,
|
||||
bump_time timestamptz,
|
||||
body text,
|
||||
subject text,
|
||||
thread_id bigint,
|
||||
board_thread_id bigint,
|
||||
pathpart text,
|
||||
|
@ -158,7 +160,9 @@ RETURNS TABLE (
|
|||
posts.post_id,
|
||||
posts.board_post_id,
|
||||
posts.creation_time,
|
||||
top.bump_time,
|
||||
posts.body,
|
||||
posts.subject,
|
||||
posts.thread_id
|
||||
FROM top
|
||||
JOIN posts ON top.thread_id = posts.thread_id
|
||||
|
@ -187,12 +191,15 @@ RETURNS TABLE (
|
|||
JOIN post_counts ON op_posts.thread_id = post_counts.thread_id
|
||||
JOIN threads ON op_posts.thread_id = threads.thread_id
|
||||
JOIN boards ON threads.board_id = boards.board_id
|
||||
JOIN sites ON sites.site_id = boards.site_id;
|
||||
JOIN sites ON sites.site_id = boards.site_id
|
||||
ORDER BY bump_time DESC;
|
||||
$$ LANGUAGE sql;
|
||||
|
||||
SELECT * FROM fetch_catalog(NOW() - INTERVAL '1y', 1001);
|
||||
|
||||
SELECT * FROM fetch_catalog(NOW(), 2000);
|
||||
SELECT * FROM fetch_catalog(NOW(), 1000);
|
||||
|
||||
SELECT count(*) FROM posts;
|
||||
|
||||
-- CREATE INDEX idx_posts_thread_board ON posts (thread_id, board_post_id);
|
||||
ANALYZE posts;
|
||||
|
|
|
@ -211,6 +211,7 @@ RETURNS TABLE (
|
|||
post_id bigint,
|
||||
board_post_id bigint,
|
||||
creation_time timestamptz,
|
||||
bump_time timestamptz,
|
||||
body text,
|
||||
subject text,
|
||||
thread_id bigint,
|
||||
|
@ -230,6 +231,7 @@ RETURNS TABLE (
|
|||
posts.post_id,
|
||||
posts.board_post_id,
|
||||
posts.creation_time,
|
||||
top.bump_time,
|
||||
posts.body,
|
||||
posts.subject,
|
||||
posts.thread_id
|
||||
|
@ -260,7 +262,8 @@ RETURNS TABLE (
|
|||
JOIN post_counts ON op_posts.thread_id = post_counts.thread_id
|
||||
JOIN threads ON op_posts.thread_id = threads.thread_id
|
||||
JOIN boards ON threads.board_id = boards.board_id
|
||||
JOIN sites ON sites.site_id = boards.site_id;
|
||||
JOIN sites ON sites.site_id = boards.site_id
|
||||
ORDER BY bump_time DESC;
|
||||
$$ LANGUAGE sql;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue