Migrating from MySQL to Postgres on Rails 3

Besides deleting some MySQL queries, the migration was pretty smooth. The problem is that during development there are much more queries in the database 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 

Each query results in 3-8 additional queries as indicated above. What is happening and why? One of the problems is that developmentement.log is bloated and not readable. I spend a lot of time scrolling between these queries that are looking for the right thing ...

Update: Tue Sep 21

This is not a request type. All requests generate this type 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 line in the set ree-1.8.7-2010.02>

+6
ruby-on-rails postgresql ruby-on-rails-3
source share
2 answers

I stole it from another post. Perhaps you should take a look at http://github.com/dolzenko/silent-postgres This plugin removes these requests. This log noise is due to the high level of postgresql log.

+4
source share

The second query is used by your application to obtain information about the data type used and to check whether the column is null or not. If you use pgAdmin3, you will also see many such requests, just to get metadata of the results. Most applications do not need such requests; this is mainly useful in development and for tools such as pgAdmin.

+1
source share

All Articles