Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku Row Count Incorrect

Tags:

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!

like image 908
Averenix Avatar asked Oct 03 '12 04:10

Averenix


1 Answers

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.

like image 106
microspino Avatar answered Sep 19 '22 15:09

microspino