Compare commits

...

12 commits

Author SHA1 Message Date
dullbananas 83ef4274b7
Merge 48d9516f9a into b459949f57 2024-04-26 05:35:44 +00:00
Dessalines b459949f57 Version 0.19.4-beta.5 2024-04-25 19:59:24 -04:00
Dessalines 93f5df2d2a
Adding post_id desc to all post_aggregates indexes. Fixes #4618 (#4662)
* Adding post_id desc to all post_aggregates indexes. Fixes #4618

* Running pg_format

* Not rebuilding indexes which had no changes.
2024-04-25 18:19:02 -04:00
dullbananas 48d9516f9a
Update actor_language.rs 2024-04-20 19:03:21 -07:00
dullbananas bb1c918f00
Update actor_language.rs 2024-04-20 18:24:48 -07:00
dullbananas 5aec288bf9
Update actor_language.rs 2024-04-20 18:17:10 -07:00
dullbananas 4ec4582ec6
Update actor_language.rs 2024-04-20 18:06:18 -07:00
dullbananas cea8cf36fe
community 2024-04-20 14:20:20 -07:00
dullbananas fad321efc6
site 2024-04-20 14:12:26 -07:00
dullbananas c2c3003365
Merge branch 'main' into optimize-transactions 2024-04-20 14:02:32 -07:00
dullbananas 154573a49c
Update actor_language.rs 2024-04-09 06:25:01 -07:00
dullbananas 4cd16d8794
Remove useless transaction in actor_language.rs 2024-04-07 14:47:56 -07:00
6 changed files with 324 additions and 76 deletions

26
Cargo.lock generated
View file

@ -2582,7 +2582,7 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "lemmy_api" name = "lemmy_api"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"actix-web", "actix-web",
@ -2611,7 +2611,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_api_common" name = "lemmy_api_common"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"actix-web", "actix-web",
@ -2649,7 +2649,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_api_crud" name = "lemmy_api_crud"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"accept-language", "accept-language",
"activitypub_federation", "activitypub_federation",
@ -2672,7 +2672,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_apub" name = "lemmy_apub"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"actix-web", "actix-web",
@ -2710,7 +2710,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_perf" name = "lemmy_db_perf"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"clap", "clap",
@ -2725,7 +2725,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_schema" name = "lemmy_db_schema"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"anyhow", "anyhow",
@ -2765,7 +2765,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views" name = "lemmy_db_views"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"chrono", "chrono",
@ -2787,7 +2787,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views_actor" name = "lemmy_db_views_actor"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"chrono", "chrono",
"diesel", "diesel",
@ -2807,7 +2807,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_db_views_moderator" name = "lemmy_db_views_moderator"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"diesel", "diesel",
"diesel-async", "diesel-async",
@ -2819,7 +2819,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_federate" name = "lemmy_federate"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"anyhow", "anyhow",
@ -2842,7 +2842,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_routes" name = "lemmy_routes"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"actix-web", "actix-web",
@ -2867,7 +2867,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_server" name = "lemmy_server"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"activitypub_federation", "activitypub_federation",
"actix-cors", "actix-cors",
@ -2910,7 +2910,7 @@ dependencies = [
[[package]] [[package]]
name = "lemmy_utils" name = "lemmy_utils"
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
dependencies = [ dependencies = [
"actix-web", "actix-web",
"anyhow", "anyhow",

View file

@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "0.19.4-beta.4" version = "0.19.4-beta.5"
edition = "2021" edition = "2021"
description = "A link aggregator for the fediverse" description = "A link aggregator for the fediverse"
license = "AGPL-3.0" license = "AGPL-3.0"
@ -88,17 +88,17 @@ unused_self = "deny"
unwrap_used = "deny" unwrap_used = "deny"
[workspace.dependencies] [workspace.dependencies]
lemmy_api = { version = "=0.19.4-beta.4", path = "./crates/api" } lemmy_api = { version = "=0.19.4-beta.5", path = "./crates/api" }
lemmy_api_crud = { version = "=0.19.4-beta.4", path = "./crates/api_crud" } lemmy_api_crud = { version = "=0.19.4-beta.5", path = "./crates/api_crud" }
lemmy_apub = { version = "=0.19.4-beta.4", path = "./crates/apub" } lemmy_apub = { version = "=0.19.4-beta.5", path = "./crates/apub" }
lemmy_utils = { version = "=0.19.4-beta.4", path = "./crates/utils", default-features = false } lemmy_utils = { version = "=0.19.4-beta.5", path = "./crates/utils", default-features = false }
lemmy_db_schema = { version = "=0.19.4-beta.4", path = "./crates/db_schema" } lemmy_db_schema = { version = "=0.19.4-beta.5", path = "./crates/db_schema" }
lemmy_api_common = { version = "=0.19.4-beta.4", path = "./crates/api_common" } lemmy_api_common = { version = "=0.19.4-beta.5", path = "./crates/api_common" }
lemmy_routes = { version = "=0.19.4-beta.4", path = "./crates/routes" } lemmy_routes = { version = "=0.19.4-beta.5", path = "./crates/routes" }
lemmy_db_views = { version = "=0.19.4-beta.4", path = "./crates/db_views" } lemmy_db_views = { version = "=0.19.4-beta.5", path = "./crates/db_views" }
lemmy_db_views_actor = { version = "=0.19.4-beta.4", path = "./crates/db_views_actor" } lemmy_db_views_actor = { version = "=0.19.4-beta.5", path = "./crates/db_views_actor" }
lemmy_db_views_moderator = { version = "=0.19.4-beta.4", path = "./crates/db_views_moderator" } lemmy_db_views_moderator = { version = "=0.19.4-beta.5", path = "./crates/db_views_moderator" }
lemmy_federate = { version = "=0.19.4-beta.4", path = "./crates/federate" } lemmy_federate = { version = "=0.19.4-beta.5", path = "./crates/federate" }
activitypub_federation = { version = "0.5.4", default-features = false, features = [ activitypub_federation = { version = "0.5.4", default-features = false, features = [
"actix-web", "actix-web",
] } ] }

View file

@ -43,20 +43,13 @@ impl LocalUserLanguage {
}; };
let conn = &mut get_conn(pool).await?; let conn = &mut get_conn(pool).await?;
conn let langs = local_user_language
.build_transaction() .filter(local_user_id.eq(for_local_user_id))
.run(|conn| { .order(language_id)
Box::pin(async move { .select(language_id)
let langs = local_user_language .get_results(conn)
.filter(local_user_id.eq(for_local_user_id)) .await?;
.order(language_id) convert_read_languages(conn, langs).await
.select(language_id)
.get_results(conn)
.await?;
convert_read_languages(conn, langs).await
}) as _
})
.await
} }
/// Update the user's languages. /// Update the user's languages.
@ -90,24 +83,33 @@ impl LocalUserLanguage {
.build_transaction() .build_transaction()
.run(|conn| { .run(|conn| {
Box::pin(async move { Box::pin(async move {
use crate::schema::local_user_language::dsl::{local_user_id, local_user_language}; use crate::schema::local_user_language::dsl::{
// Clear the current user languages language_id,
delete(local_user_language.filter(local_user_id.eq(for_local_user_id))) local_user_id,
.execute(conn) local_user_language,
.await?; };
// Delete old languages, not including new languages
let delete_old = delete(local_user_language)
.filter(local_user_id.eq(for_local_user_id))
.filter(language_id.ne_all(&lang_ids))
.execute(conn);
let forms = lang_ids let forms = lang_ids
.into_iter() .iter()
.map(|l| LocalUserLanguageForm { .map(|l| LocalUserLanguageForm {
local_user_id: for_local_user_id, local_user_id: for_local_user_id,
language_id: l, language_id: l,
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
insert_into(local_user_language) // Insert new languages
let insert_new = insert_into(local_user_language)
.values(forms) .values(forms)
.execute(conn) .on_conflict((language_id, local_user_id))
.await?; .do_nothing()
.execute(conn);
tokio::try_join!(delete_old, insert_new)?;
Ok(()) Ok(())
}) as _ }) as _
}) })
@ -159,25 +161,30 @@ impl SiteLanguage {
.build_transaction() .build_transaction()
.run(|conn| { .run(|conn| {
Box::pin(async move { Box::pin(async move {
use crate::schema::site_language::dsl::{site_id, site_language}; use crate::schema::site_language::dsl::{language_id, site_id, site_language};
// Clear the current languages // Delete old languages, not including new languages
delete(site_language.filter(site_id.eq(for_site_id))) let delete_old = delete(site_language)
.execute(conn) .filter(site_id.eq(for_site_id))
.await?; .filter(language_id.ne_all(&lang_ids))
.execute(conn);
let forms = lang_ids let forms = lang_ids
.into_iter() .iter()
.map(|l| SiteLanguageForm { .map(|l| SiteLanguageForm {
site_id: for_site_id, site_id: for_site_id,
language_id: l, language_id: l,
}) })
.collect::<Vec<_>>(); .collect::<Vec<_>>();
insert_into(site_language) // Insert new languages
let insert_new = insert_into(site_language)
.values(forms) .values(forms)
.get_result::<Self>(conn) .on_conflict((site_id, language_id))
.await?; .do_nothing()
.execute(conn);
tokio::try_join!(delete_old, insert_new)?;
CommunityLanguage::limit_languages(conn, instance_id).await?; CommunityLanguage::limit_languages(conn, instance_id).await?;
@ -278,8 +285,8 @@ impl CommunityLanguage {
} }
let form = lang_ids let form = lang_ids
.into_iter() .iter()
.map(|language_id| CommunityLanguageForm { .map(|&language_id| CommunityLanguageForm {
community_id: for_community_id, community_id: for_community_id,
language_id, language_id,
}) })
@ -289,25 +296,25 @@ impl CommunityLanguage {
.build_transaction() .build_transaction()
.run(|conn| { .run(|conn| {
Box::pin(async move { Box::pin(async move {
use crate::schema::community_language::dsl::{community_id, community_language}; use crate::schema::community_language::dsl::{
use diesel::result::DatabaseErrorKind::UniqueViolation; community_id,
// Clear the current languages community_language,
delete(community_language.filter(community_id.eq(for_community_id))) language_id,
.execute(conn) };
.await?; // Delete old languages, not including new languages
let delete_old = delete(community_language)
.filter(community_id.eq(for_community_id))
.filter(language_id.ne_all(&lang_ids))
.execute(conn);
let insert_res = insert_into(community_language) // Insert new languages
let insert_new = insert_into(community_language)
.values(form) .values(form)
.get_result::<Self>(conn) .on_conflict((community_id, language_id))
.await; .do_nothing()
.execute(conn);
if let Err(Error::DatabaseError(UniqueViolation, _info)) = insert_res { tokio::try_join!(delete_old, insert_new)?;
// race condition: this function was probably called simultaneously from another caller. ignore error
// tracing::warn!("unique error: {_info:#?}");
// _info.constraint_name() should be = "community_language_community_id_language_id_key"
return Ok(());
}
insert_res?;
Ok(()) Ok(())
}) as _ }) as _

@ -1 +1 @@
Subproject commit c88dd1e3b36ee1617f1b86acf94c1b7946e97cd4 Subproject commit 866e4056656755f7b31e20094b46391e6931e3e7

View file

@ -0,0 +1,120 @@
DROP INDEX idx_post_aggregates_community_active;
DROP INDEX idx_post_aggregates_community_controversy;
DROP INDEX idx_post_aggregates_community_hot;
DROP INDEX idx_post_aggregates_community_most_comments;
DROP INDEX idx_post_aggregates_community_newest_comment_time;
DROP INDEX idx_post_aggregates_community_newest_comment_time_necro;
DROP INDEX idx_post_aggregates_community_published;
DROP INDEX idx_post_aggregates_community_published_asc;
DROP INDEX idx_post_aggregates_community_scaled;
DROP INDEX idx_post_aggregates_community_score;
DROP INDEX idx_post_aggregates_featured_community_active;
DROP INDEX idx_post_aggregates_featured_community_controversy;
DROP INDEX idx_post_aggregates_featured_community_hot;
DROP INDEX idx_post_aggregates_featured_community_most_comments;
DROP INDEX idx_post_aggregates_featured_community_newest_comment_time;
DROP INDEX idx_post_aggregates_featured_community_newest_comment_time_necr;
DROP INDEX idx_post_aggregates_featured_community_published;
DROP INDEX idx_post_aggregates_featured_community_published_asc;
DROP INDEX idx_post_aggregates_featured_community_scaled;
DROP INDEX idx_post_aggregates_featured_community_score;
DROP INDEX idx_post_aggregates_featured_local_active;
DROP INDEX idx_post_aggregates_featured_local_controversy;
DROP INDEX idx_post_aggregates_featured_local_hot;
DROP INDEX idx_post_aggregates_featured_local_most_comments;
DROP INDEX idx_post_aggregates_featured_local_newest_comment_time;
DROP INDEX idx_post_aggregates_featured_local_newest_comment_time_necro;
DROP INDEX idx_post_aggregates_featured_local_published;
DROP INDEX idx_post_aggregates_featured_local_published_asc;
DROP INDEX idx_post_aggregates_featured_local_scaled;
DROP INDEX idx_post_aggregates_featured_local_score;
CREATE INDEX idx_post_aggregates_community_active ON public.post_aggregates USING btree (community_id, featured_local DESC, hot_rank_active DESC, published DESC);
CREATE INDEX idx_post_aggregates_community_controversy ON public.post_aggregates USING btree (community_id, featured_local DESC, controversy_rank DESC);
CREATE INDEX idx_post_aggregates_community_hot ON public.post_aggregates USING btree (community_id, featured_local DESC, hot_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_community_most_comments ON public.post_aggregates USING btree (community_id, featured_local DESC, comments DESC, published DESC);
CREATE INDEX idx_post_aggregates_community_newest_comment_time ON public.post_aggregates USING btree (community_id, featured_local DESC, newest_comment_time DESC);
CREATE INDEX idx_post_aggregates_community_newest_comment_time_necro ON public.post_aggregates USING btree (community_id, featured_local DESC, newest_comment_time_necro DESC);
CREATE INDEX idx_post_aggregates_community_published ON public.post_aggregates USING btree (community_id, featured_local DESC, published DESC);
CREATE INDEX idx_post_aggregates_community_published_asc ON public.post_aggregates USING btree (community_id, featured_local DESC, public.reverse_timestamp_sort (published) DESC);
CREATE INDEX idx_post_aggregates_community_scaled ON public.post_aggregates USING btree (community_id, featured_local DESC, scaled_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_community_score ON public.post_aggregates USING btree (community_id, featured_local DESC, score DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_active ON public.post_aggregates USING btree (community_id, featured_community DESC, hot_rank_active DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_controversy ON public.post_aggregates USING btree (community_id, featured_community DESC, controversy_rank DESC);
CREATE INDEX idx_post_aggregates_featured_community_hot ON public.post_aggregates USING btree (community_id, featured_community DESC, hot_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_most_comments ON public.post_aggregates USING btree (community_id, featured_community DESC, comments DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_newest_comment_time ON public.post_aggregates USING btree (community_id, featured_community DESC, newest_comment_time DESC);
CREATE INDEX idx_post_aggregates_featured_community_newest_comment_time_necr ON public.post_aggregates USING btree (community_id, featured_community DESC, newest_comment_time_necro DESC);
CREATE INDEX idx_post_aggregates_featured_community_published ON public.post_aggregates USING btree (community_id, featured_community DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_published_asc ON public.post_aggregates USING btree (community_id, featured_community DESC, public.reverse_timestamp_sort (published) DESC);
CREATE INDEX idx_post_aggregates_featured_community_scaled ON public.post_aggregates USING btree (community_id, featured_community DESC, scaled_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_community_score ON public.post_aggregates USING btree (community_id, featured_community DESC, score DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_active ON public.post_aggregates USING btree (featured_local DESC, hot_rank_active DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_controversy ON public.post_aggregates USING btree (featured_local DESC, controversy_rank DESC);
CREATE INDEX idx_post_aggregates_featured_local_hot ON public.post_aggregates USING btree (featured_local DESC, hot_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_most_comments ON public.post_aggregates USING btree (featured_local DESC, comments DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_newest_comment_time ON public.post_aggregates USING btree (featured_local DESC, newest_comment_time DESC);
CREATE INDEX idx_post_aggregates_featured_local_newest_comment_time_necro ON public.post_aggregates USING btree (featured_local DESC, newest_comment_time_necro DESC);
CREATE INDEX idx_post_aggregates_featured_local_published ON public.post_aggregates USING btree (featured_local DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_published_asc ON public.post_aggregates USING btree (featured_local DESC, public.reverse_timestamp_sort (published) DESC);
CREATE INDEX idx_post_aggregates_featured_local_scaled ON public.post_aggregates USING btree (featured_local DESC, scaled_rank DESC, published DESC);
CREATE INDEX idx_post_aggregates_featured_local_score ON public.post_aggregates USING btree (featured_local DESC, score DESC, published DESC);

View file

@ -0,0 +1,121 @@
-- Add , post_id DESC to all these
DROP INDEX idx_post_aggregates_community_active;
DROP INDEX idx_post_aggregates_community_controversy;
DROP INDEX idx_post_aggregates_community_hot;
DROP INDEX idx_post_aggregates_community_most_comments;
DROP INDEX idx_post_aggregates_community_newest_comment_time;
DROP INDEX idx_post_aggregates_community_newest_comment_time_necro;
DROP INDEX idx_post_aggregates_community_published;
DROP INDEX idx_post_aggregates_community_published_asc;
DROP INDEX idx_post_aggregates_community_scaled;
DROP INDEX idx_post_aggregates_community_score;
DROP INDEX idx_post_aggregates_featured_community_active;
DROP INDEX idx_post_aggregates_featured_community_controversy;
DROP INDEX idx_post_aggregates_featured_community_hot;
DROP INDEX idx_post_aggregates_featured_community_most_comments;
DROP INDEX idx_post_aggregates_featured_community_newest_comment_time;
DROP INDEX idx_post_aggregates_featured_community_newest_comment_time_necr;
DROP INDEX idx_post_aggregates_featured_community_published;
DROP INDEX idx_post_aggregates_featured_community_published_asc;
DROP INDEX idx_post_aggregates_featured_community_scaled;
DROP INDEX idx_post_aggregates_featured_community_score;
DROP INDEX idx_post_aggregates_featured_local_active;
DROP INDEX idx_post_aggregates_featured_local_controversy;
DROP INDEX idx_post_aggregates_featured_local_hot;
DROP INDEX idx_post_aggregates_featured_local_most_comments;
DROP INDEX idx_post_aggregates_featured_local_newest_comment_time;
DROP INDEX idx_post_aggregates_featured_local_newest_comment_time_necro;
DROP INDEX idx_post_aggregates_featured_local_published;
DROP INDEX idx_post_aggregates_featured_local_published_asc;
DROP INDEX idx_post_aggregates_featured_local_scaled;
DROP INDEX idx_post_aggregates_featured_local_score;
CREATE INDEX idx_post_aggregates_community_active ON public.post_aggregates USING btree (community_id, featured_local DESC, hot_rank_active DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_controversy ON public.post_aggregates USING btree (community_id, featured_local DESC, controversy_rank DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_hot ON public.post_aggregates USING btree (community_id, featured_local DESC, hot_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_most_comments ON public.post_aggregates USING btree (community_id, featured_local DESC, comments DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_newest_comment_time ON public.post_aggregates USING btree (community_id, featured_local DESC, newest_comment_time DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_newest_comment_time_necro ON public.post_aggregates USING btree (community_id, featured_local DESC, newest_comment_time_necro DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_published ON public.post_aggregates USING btree (community_id, featured_local DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_published_asc ON public.post_aggregates USING btree (community_id, featured_local DESC, public.reverse_timestamp_sort (published) DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_scaled ON public.post_aggregates USING btree (community_id, featured_local DESC, scaled_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_community_score ON public.post_aggregates USING btree (community_id, featured_local DESC, score DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_active ON public.post_aggregates USING btree (community_id, featured_community DESC, hot_rank_active DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_controversy ON public.post_aggregates USING btree (community_id, featured_community DESC, controversy_rank DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_hot ON public.post_aggregates USING btree (community_id, featured_community DESC, hot_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_most_comments ON public.post_aggregates USING btree (community_id, featured_community DESC, comments DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_newest_comment_time ON public.post_aggregates USING btree (community_id, featured_community DESC, newest_comment_time DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_newest_comment_time_necr ON public.post_aggregates USING btree (community_id, featured_community DESC, newest_comment_time_necro DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_published ON public.post_aggregates USING btree (community_id, featured_community DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_published_asc ON public.post_aggregates USING btree (community_id, featured_community DESC, public.reverse_timestamp_sort (published) DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_scaled ON public.post_aggregates USING btree (community_id, featured_community DESC, scaled_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_community_score ON public.post_aggregates USING btree (community_id, featured_community DESC, score DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_active ON public.post_aggregates USING btree (featured_local DESC, hot_rank_active DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_controversy ON public.post_aggregates USING btree (featured_local DESC, controversy_rank DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_hot ON public.post_aggregates USING btree (featured_local DESC, hot_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_most_comments ON public.post_aggregates USING btree (featured_local DESC, comments DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_newest_comment_time ON public.post_aggregates USING btree (featured_local DESC, newest_comment_time DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_newest_comment_time_necro ON public.post_aggregates USING btree (featured_local DESC, newest_comment_time_necro DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_published ON public.post_aggregates USING btree (featured_local DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_published_asc ON public.post_aggregates USING btree (featured_local DESC, public.reverse_timestamp_sort (published) DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_scaled ON public.post_aggregates USING btree (featured_local DESC, scaled_rank DESC, published DESC, post_id DESC);
CREATE INDEX idx_post_aggregates_featured_local_score ON public.post_aggregates USING btree (featured_local DESC, score DESC, published DESC, post_id DESC);