From 3997f8ea966b6fd6bac7966f61ab4b3447e55b77 Mon Sep 17 00:00:00 2001 From: mylake Date: Fri, 10 Mar 2017 14:39:42 +0800 Subject: =?UTF-8?q?Use=20=E2=80=9Cdistinct=E2=80=9D=20to=20filter=20redund?= =?UTF-8?q?ant=20types=20from=20pg=5Ftypeto=20reduce=20memory=20bloat=20es?= =?UTF-8?q?pecially=20in=20multi-schema=20structure=20database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'activerecord') 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 -- cgit v1.2.3