postgresql 找出heroku数据库大小的最快方法
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4220231/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Quickest way to find out heroku database size
提问by HymanCA
What is the quickest way to find out the currentsize of my shared database in Heroku?
在 Heroku 中找出共享数据库当前大小的最快方法是什么?
回答by jordinl
running heroku info
shows:
跑步heroku info
节目:
Data size: 480k
Addons: Basic Logging, Shared Database 5MB
Data size being the size of the shared database, here with a limit of 5MB.
数据大小是共享数据库的大小,这里限制为 5MB。
回答by Josh
From the same doc page as posted by nate c:
来自 nate c 发布的同一文档页面:
heroku pg:info
This only seems to work if you're not using the shared DB, but using PG as an add-on
这似乎仅在您不使用共享数据库,而是使用 PG 作为附加组件时才有效
Also, make sure your heroku gem is up to date:
另外,请确保您的 heroku gem 是最新的:
sudo gem update heroku
Any ideas on how to see the size of a shared db? I just did a heroku db:pull and then a mysqldump and looked at the file size, figured that was a good rough estimate.
关于如何查看共享数据库大小的任何想法?我只是做了一个 heroku db:pull 然后一个 mysqldump 并查看了文件大小,认为这是一个很好的粗略估计。
回答by pixelearth
The new way seems to be:
新方法似乎是:
heroku pg:info -a myapp
You'll see something like:
你会看到类似的东西:
=== HEROKU_POSTGRESQL_PURPLE_URL (DATABASE_URL)
Plan: Dev
Status: available
Connections: 1
PG Version: 9.1.5
Created: 2012-10-19 01:27 UTC
Data Size: 12.1 MB
Tables: 31
Rows: 36068/10000 (Above limits, access disruption imminent)
Fork/Follow: Unavailable
回答by Josh
Based on Nate's answer:
基于内特的回答:
For sharedDB w/o installing Postgres on your local machine
对于没有在本地机器上安装 Postgres 的共享数据库
heroku console
ActiveRecord::Base.connection.execute("SELECT pg_size_pretty(pg_database_size('postgres'))").first
'postgres' is the name of my shared DB, when I put in template0 or template1 I get the same number back.
'postgres' 是我的共享数据库的名称,当我输入 template0 或 template1 时,我得到相同的数字。
回答by nate c
You can log into Posgtgresql directly.
您可以直接登录 Posgtgresql。
type heroku pg:psql
.
输入heroku pg:psql
.
But you have to have postgres on your local system as well so you can use pgsql
(which is the command line interface for pg.)
但是您的本地系统上也必须有 postgres,以便您可以使用pgsql
(这是 pg 的命令行界面。)
If you do not know what the db name is then type \l in
pgsql to list databases. (postgres, template0, and template1 are system databases in every install.)
如果您不知道 db 名称是什么,则键入\l in
pgsql 以列出数据库。(postgres、template0 和 template1 是每次安装中的系统数据库。)
Then
SELECT pg_size_pretty(pg_database_size('dbname'));
然后
SELECT pg_size_pretty(pg_database_size('dbname'));
回答by msroot
In heroku postgres panel you can see everything https://postgres.heroku.com/
在 heroku postgres 面板中,您可以看到所有内容 https://postgres.heroku.com/