From d18e48952c33c4ba20cd6eb09ec178363ce6d019 Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Tue, 24 Jun 2014 17:05:51 +0300 Subject: [PATCH 1/2] Use different user.construct_public_followings_sql query depending on database backend. This is done for performance reasons as a temporary fix for problems with 0.4.0.0 on MySQL. This madness is explained in issue https://github.com/diaspora/diaspora/issues/5014. (cherry picked from commit 80075c13f4e45de4a1cc7b305b213ee693c66619) --- app/models/user/querying.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/user/querying.rb b/app/models/user/querying.rb index 878d80d4f..ac5a800df 100644 --- a/app/models/user/querying.rb +++ b/app/models/user/querying.rb @@ -69,7 +69,16 @@ module User::Querying def construct_public_followings_sql(opts) Rails.logger.debug("[EVIL-QUERY] user.construct_public_followings_sql") - query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false) + + # For PostgreSQL and MySQL/MariaDB we use a different query + # see issue: https://github.com/diaspora/diaspora/issues/5014 + if AppConfig.postgres? + query = opts[:klass].where(:author_id => Person.in_aspects(opts[:by_members_of]).select("people.id"), :public => true, :pending => false) + else + aspects = Aspect.where(:id => opts[:by_members_of]) + person_ids = Person.connection.select_values(people_in_aspects(aspects).select("people.id").to_sql) + query = opts[:klass].where(:author_id => person_ids, :public => true, :pending => false) + end unless(opts[:klass] == Photo) query = query.where(:type => opts[:type]) From 90dd5d38681634df32163eb3208e5f435aa8c69b Mon Sep 17 00:00:00 2001 From: Jason Robinson Date: Tue, 24 Jun 2014 22:01:12 +0300 Subject: [PATCH 2/2] Bump to 0.4.0.1 --- Changelog.md | 6 ++++++ config/defaults.yml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index cc933fb86..a4693905a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,9 @@ +# 0.4.0.1 + +## Bug fixes + +Fix performance regression on stream loading with MySQL/MariaDB database backends [#5014](https://github.com/diaspora/diaspora/issues/5014). + # 0.4.0.0 ## Ensure account deletions are run diff --git a/config/defaults.yml b/config/defaults.yml index 1109be74c..5a1c0e643 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -4,7 +4,7 @@ defaults: version: - number: "0.4.0.0" # Do not touch unless doing a release, do not backport the version number that's in master but keep develop to always say "head" + number: "0.4.0.1" # Do not touch unless doing a release, do not backport the version number that's in master but keep develop to always say "head" heroku: false environment: url: "http://localhost:3000/"