views:

125

answers:

2

Aside from removal of some MySQL specific queries, the migration was pretty smooth. The problem now is, that during developement there is a lot more queries to the DB than before.

Started GET "/profiles/data" for 127.0.0.1 at Tue Sep 21 10:26:18 +0200 2010
 Processing by ProfilesController#data as JSON
 User Load (24.3ms)  SELECT "users".* FROM "users" ORDER BY updated_at DESC LIMIT 1
 CACHE (0.0ms)  SELECT "users".* FROM "users" ORDER BY updated_at DESC LIMIT 1
 SQL (10.5ms)   SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull
 FROM pg_attribute a LEFT JOIN pg_attrdef d
 ON  a.attrelid = d.adrelid AND a.attnum = d.adnum
 WHERE a.attrelid = '"users"'::regclass
 AND a.attnum > 0 AND NOT a.attisdropped
 ORDER BY a.attnum

Every single query results in 3-8 additional queries like the above. What and why is happening? One of the problems now is, that developement.log is bloated and unreadable. I waste loads of time scrolling inbetween those queries looking for the right thing...

Update: Tue Sep 21

This is not related to the query type. All the queries are generating this kind of stuph:

ree-1.8.7-2010.02 > User.first
  SQL (0.3ms)  SHOW client_min_messages
  SQL (2.0ms)  SET client_min_messages TO 'panic'
  SQL (6.3ms)  SET standard_conforming_strings = on
  SQL (18.3ms)  SET client_min_messages TO 'notice'
  SQL (15.6ms)  SET time zone 'UTC'
  SQL (17.2ms)  SHOW TIME ZONE
  SQL (23.8ms)   SELECT tablename FROM pg_tables WHERE schemaname = ANY (current_schemas(false)) 
  User Load (162.4ms)  SELECT "users".* FROM "users" LIMIT 1
  SQL (7.5ms)   SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc,
    a.attnotnull FROM pg_attribute a LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid
    AND a.attnum = d.adnum WHERE a.attrelid = '"users"'::regclass AND a.attnum > 0 AND
    NOT a.attisdropped ORDER BY a.attnum 

[...] 1 row in set ree-1.8.7-2010.02 >

A: 

The second query is used by your application to get information about the datatype used and to see if the column is nullable or not. If you're using pgAdmin3 you'll see a lot these type of queries as well, just to get meta data of the results. Most applications don't need queries like this, it's mostly usefull during development and for tools like pgAdmin.

Frank Heikens
Ok, but is there a way to disable this during developement. I can't trace my log anymore now. Its getting really annoying...
mdrozdziel
Edit postgresql.conf and set log_min_duration_statement to 1000. 1000 = 1000 milliseconds, 1 second. You could also set log_min_error_statement to ERROR. You have to reload postgresql.conf as a superuser: SELECT pg_reload_conf(); You could restart your databaseserver as well.
Frank Heikens
+1  A: 

I stole this from another post: You might want to have a look at http://github.com/dolzenko/silent-postgres That plugin strips those queries out. Those log noise occurs because of the high postgresql log level.

baldmark
This works like a charm, thanks!
mdrozdziel