Heroku 行计数不正确 [英] Heroku Row Count Incorrect

查看:20
本文介绍了Heroku 行计数不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在为我的一个应用程序使用 heroku,但今天它关闭了,因为行数已超过 10,000 行.

I've been using heroku for one of my applications and it got shutdown today because the row count has exceeded 10,000 rows.

我不明白这个数字是如何得出的,因为 rails 告诉我我在数据库中只有大约 2000 条记录.

I don't understanding how this figure is arrived at though, as rails tells me I only have around 2000 records in the db.

运行 pg:info,我看到以下内容:

Running a pg:info, I see the following:

Plan:        Dev
Status:      available
Connections: 1
PG Version:  9.1.5
Created:     2012-09-25 03:12 UTC
Data Size:   11.0 MB
Tables:      9
Rows:        15686/10000 (Write access revoked)
Fork/Follow: Unavailable

谁能向我解释一下,尽管数据库中只有 2,000 条记录,但我似乎有 15,000 行?

Can anyone explain to me how I seem to have 15,000 rows despite only have 2,000 records in the database?

谢谢!

推荐答案

仅靠 Rails 是不够的.Heroku 有一个不错的 SQL 控制台,您可以通过以下方式访问:

Rails alone is not enough. Heroku has a nice SQL console that you can access with:

heroku pg:psql YOUR_DB_URL

然后您可以编写此查询来获取每个表的记录排名:

then you can write this query to obtain a rank of records per table:

SELECT schemaname,relname,n_live_tup 
  FROM pg_stat_user_tables 
  ORDER BY n_live_tup DESC;

如果您只需要更新的数字.行数,您可以使用

If you need only the updated num. of rows, you can use

SELECT sum(n_live_tup) FROM pg_stat_user_tables;

请注意,您可以在配置中同时拥有新的开发计划数据库和旧的 SHARED 数据库(通过 heroku pg:info 访问它).您必须插入正确的 db url,可能是带有颜色的那个.

Please note that you can have both the new dev plan db and the old SHARED one in your config (access it by heroku pg:info). You have to insert the correct db url, probably the one with a color.

在任何 sql truncateRows 计数之间允许 30 分钟的延迟更新.

Allow a 30 mins delay between any sql truncate and the Rows count to update.

顺便说一句,http://heroku.com 上的网络控制台在我的情况下已更新为正确的编号.在我的 sql 查询期间.可能是 heroku toolbelt 控制台更新,速度较慢.

BTW the web console on http://heroku.com in my case was updated with the correct num. during my sql queries. May be heroku toolbelt console updates, are slower.

这篇关于Heroku 行计数不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆