Find the size of a table in Postgres

You often need to know the size of a table in postgres and there is no particularly easy way to get that information directly from the psql client.

Fortunately, all of the information is in there and is available through nice simple functions.

All you have to do is pull it together and a stock query will normally do.

The below query will get you a list of all of the tables in your database, it will show you the size of the associated indexes as well as the size of the associated TOAST objects.

If you want the size of your database, I would tend to just do a ‘\l+’ in psql but if you want to do it in SQL for some reason then you can just do:

And then if you want the size of all of your databases then its a simple change so that it looks like:

And finally, if you want a size breakdown of all of the objects in your database – so that you can see all of the indexes as well as the tables then you can find that with:

Can you improve your Oracle database using Postgres?

Oracle is a great database. It is cutting edge and it has a huge team of developers behind it as well as massive funding.


There are not any areas where it lacks anything major that exists in other comparable databases.

The problem with Oracle is both that it is expensive in the first place, but also that all of the extras are chargeable and also expensive!

Continue reading “Can you improve your Oracle database using Postgres?”

High Availability Options in Oracle vs Postgres

Oracle is the database to beat in terms performance and features or at least is positioned that way. More importantly, if you are thinking of migrating from Oracle to Postgres to save money, you need to know that your new database has at least the same features at the one that you are moving from.


High availability is one of the most important concepts and features for a database system. For most enterprise level applications, downtime has a direct financial cost and the actual loss of some or all of your data would be catastrophic. 
You need to know that the system that you are moving to can protect your data as well as the system that you are on at the moment.

Continue reading “High Availability Options in Oracle vs Postgres”

Should you migrate to Postgres from Oracle?

The Oracle database has been the gold standard for enterprise applications for a long time now. It has great performance, solid reliability and most of the features that you could want are available. The big problem is that it is expensive. And I mean REALLY expensive. That’s just for the base product as well. All of the extra features that you might want are chargeable extras which means that wench developing for Oracle, you often have to work without some of the more advanced features because they would cost too much.

Continue reading “Should you migrate to Postgres from Oracle?”

Postgres Vacuum and AutoVacuum.

Basics of vacuum Postgres maintains multi version consistency by keeping old versions of changes tuples instead of actually deleting them. Eventually, keeping all of those out of date versions becomes big burden in terms  of storage and performance. Eventually, you end up with bloated tableland indexes. If not felt with, eventually they would fill up tour disks but they would probably make the database unusable before then so we have a handy process to clean it all up. That is Vacuum. Postgres Vacuum goes through your tables and indexes an cleans out had tuples – that is tuples that can no longer be needed by a transaction.

Continue reading “Postgres Vacuum and AutoVacuum.”