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

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

问题描述



我不明白这是怎么回事,因为我的应用程序已经使用了heroku,并且今天它已经关闭了,因为行数已经超过了10,000行。尽管如此,因为rails告诉我在db中只有大约2000条记录。



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

 计划:开发
状态:可用
连接:1
PG版本:9.1.5
创建日期:2012-09-25 03:12 UTC
数据大小:11.0 MB
表格:9
行数:15686/10000(写入权限被撤销)
分叉/关注:不可用

任何人都可以向我解释,尽管数据库中只有2,000条记录,但我似乎拥有15,000行?



谢谢!

解决方案

仅靠Rails是不够的。 Heroku有一个很好的SQL控制台,您可以访问它:

  heroku pg:psql YOUR_DB_URL 

$ $ p

$ p> SELECT schemaname,relname,n_live_tup
FROM pg_stat_user_tables
ORDER BY n_live_tup DESC;

如果您只需要更新的数字。可以使用

  SELECT sum(n_live_tup)FROM pg_stat_user_tables; 

请注意,您可以在您的配置中同时安装新的开发计划数据库和旧的共享数据库通过 heroku pg:info )访问它。



允许在任何sql truncate

顺着> //heroku.comrel =noreferrer> http://heroku.com 在我的情况下更新了正确的数字。在我的SQL查询期间。可能是heroku toolbelt控制台更新,速度较慢。


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

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

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

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

Thanks!

解决方案

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;

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.

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

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天全站免登陆