Averenix
Averenix

Reputation: 408

Heroku Row Count Incorrect

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!

Upvotes: 23

Views: 5358

Answers (3)

thedanotto
thedanotto

Reputation: 7327

I contacted Heroku Support on this and they ran the following command to get my numbers...

$ heroku pg:info

Upvotes: 2

lugolabs
lugolabs

Reputation: 589

30 mins weren't enough for me, so I took a backup and restored the database. Then my app came back online.

Upvotes: 0

microspino
microspino

Reputation: 7781

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.

Upvotes: 45

Related Questions