2011-12-09 10 views
5

Sto usando Ruby su Rails 3.1.1 e sto usando pg gem.Come rimuovere il rumore postgresql

Nel mio Gemfile.lock questo è ciò che ho

pg (0.11.0) 

mio registro è pieno di informazioni come quello indicato di seguito. Non ho quel rumore con sqlite3. Come posso sopprimere il rumore.

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' 

risposta

0

Credo che questo gioiello dovrebbe aiutare https://github.com/dolzenko/silent-postgres

L'utilizzo è molto semplice: basta aggiungere "silent-postgres" al tuo Gemfile.

+0

'silent-postgres' sopprime' AVVISO: 'linee e simili. La domanda riguarda una query generata ed eseguita da ActiveRecord, in particolare 'ActiveRecord :: ConnectionAdapters :: PostgreSQLAdapter # pk_and_sequence_for'. – willglynn

+0

Inoltre, non vedo perché i binari continuino a chiedere. Non vedo nulla che cambierebbe. – mcr

0

Ecco un monkeypatch ho aggiunto al config/inizializzatori al silenzio solo questo fastidioso linea di log:

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 
Problemi correlati