diff options
author | mylake <ilake.chang@gmail.com> | 2017-03-10 14:39:42 +0800 |
---|---|---|
committer | mylake <ilake.chang@gmail.com> | 2017-03-10 14:47:12 +0800 |
commit | 3997f8ea966b6fd6bac7966f61ab4b3447e55b77 (patch) | |
tree | dd375ff362499e85e3553f8a5741bf0455f93604 /activerecord/lib/active_record | |
parent | c8c1460f7a97c15dff641a30e63914991d407595 (diff) | |
download | rails-3997f8ea966b6fd6bac7966f61ab4b3447e55b77.tar.gz rails-3997f8ea966b6fd6bac7966f61ab4b3447e55b77.tar.bz2 rails-3997f8ea966b6fd6bac7966f61ab4b3447e55b77.zip |
Use “distinct” to filter redundant types from pg_typeto reduce memory bloat especially in multi-schema structure database
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index bc04565434..c7fd4763a8 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -568,13 +568,13 @@ module ActiveRecord if supports_ranges? query = <<-SQL - SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype + SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, t.typtype, t.typbasetype FROM pg_type as t LEFT JOIN pg_range as r ON oid = rngtypid SQL else query = <<-SQL - SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype + SELECT DISTINCT on (t.typname) t.oid, t.typname, t.typelem, t.typdelim, t.typinput, t.typtype, t.typbasetype FROM pg_type as t SQL end |