gpt4 book ai didi

ruby-on-rails - 从 MySQL 迁移到 Postgres on Rails 3

转载 作者:行者123 更新时间:2023-11-29 11:25:05 26 4
gpt4 key购买 nike

除了删除了一些特定于 MySQL 的查询外,迁移非常顺利。现在的问题是,在开发过程中,对数据库的查询比以前多了很多。

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

每个查询都会产生 3-8 个与上述类似的额外查询。发生了什么以及为什么会发生?现在的问题之一是 developement.log 臃肿且不可读。我浪费了大量时间在这些查询之间滚动寻找正确的东西...

更新:9 月 21 日星期二

这与查询类型无关。所有的查询都在生成这种 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 行ree-1.8.7-2010.02 >

最佳答案

我从另一篇文章中偷走了这个:你可能想看看 http://github.com/dolzenko/silent-postgres该插件删除了这些查询。这些日志噪音是由于 postgresql 日志级别高而产生的。

关于ruby-on-rails - 从 MySQL 迁移到 Postgres on Rails 3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3758531/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com