2011-12-09 18 views
5

Używam Ruby on Rails 3.1.1 i używam pg gem.Jak usunąć postgresql noise

W moim Gemfile.lock to co mam

pg (0.11.0) 

Mój dziennik jest pełen informacji jak ten podany poniżej. Nie dostaję tego hałasu z sqlite3. Jak mogę zmniejszyć hałas?

PK and serial sequence (1.6ms) SELECT attr.attname, seq.relname 
FROM pg_class seq, 
pg_attribute attr, 
pg_depend dep, 
pg_namespace name, 
pg_constraint cons 
WHERE seq.oid = dep.objid 
AND seq.relkind = 'S' 
AND attr.attrelid = dep.refobjid 
AND attr.attnum = dep.refobjsubid 
AND attr.attrelid = cons.conrelid 
AND attr.attnum = cons.conkey[1] 
AND cons.contype = 'p' 
AND dep.refobjid = '"companies_users"'::regclass 
    PK and custom sequence (0.8ms) SELECT attr.attname, 
CASE 
WHEN split_part(def.adsrc, '''', 2) ~ '.' THEN 
substr(split_part(def.adsrc, '''', 2), 
strpos(split_part(def.adsrc, '''', 2), '.')+1) 
ELSE split_part(def.adsrc, '''', 2) 
END 
FROM pg_class t 
JOIN pg_attribute attr ON (t.oid = attrelid) 
JOIN pg_attrdef def ON (adrelid = attrelid AND adnum = attnum) 
JOIN pg_constraint cons ON (conrelid = adrelid AND adnum = conkey[1]) 
WHERE t.oid = '"companies_users"'::regclass 
AND cons.contype = 'p' 
AND def.adsrc ~* 'nextval' 

Odpowiedz

0

wierzę, że ten klejnot powinien pomóc https://github.com/dolzenko/silent-postgres

Użycie jest bardzo proste: wystarczy dodać "Silent-postgres" do Gemfile.

+0

'silent-postgres' tłumi' Wskazówka: 'linie i podobne. Pytanie dotyczy kwerendy generowane i uruchamiane przez ActiveRecord, w szczególności 'ActiveRecord :: ConnectionAdapters :: PostgreSQLAdapter # pk_and_sequence_for'. – willglynn

+0

Nie rozumiem również, dlaczego tory wciąż pytają. Nie widzę niczego, co by się zmieniło. – mcr

0

Oto monkeypatch dodałem do config/incjalizatory uciszyć tylko ten jeden przykry linię dziennika:

if defined?(ActiveRecord::ConnectionAdapters::PostgreSQLAdapter) 
    module ActiveRecord 
    module ConnectionAdapters 
     class PostgreSQLAdapter 
     def pk_and_sequence_for_with_silenced_logging(table) 
      log_level = ActiveRecord::Base.logger.level 
      ActiveRecord::Base.logger.level = Logger::WARN 
      pk_and_sequence_for_without_silenced_logging(table) 
     ensure 
      ActiveRecord::Base.logger.level = log_level 
     end 
     alias_method_chain(:pk_and_sequence_for, :silenced_logging) 
     end 
    end 
    end 
end