When you download a .csv file from the internet, you might designate a download location and then write a program to pull data from that location for analysis.

Although there are significant differences between accessing data from a .csv and a PostgreSQL database, the data you’re accessing is still stored on disk. Because PostgreSQL stores data on disk, you should take care to manage that storage like any other set of files. Just as you might only want to keep the most recent version of a large .csv file on your computer, you’ll want to keep your PostgreSQL database consuming only the disk space it needs.

The space PostgreSQL uses on disk can grow in several ways. Some ways are easier to predict, for example, the addition of new tables or the addition of more data to a table. However, there are some properties of the PostgreSQL data storage system that cause disk usage to increase in non-intuitive ways. For example, table size can increase after UPDATE statements, or a DELETE statement that removes millions of rows can result in no change in total table size.

In this lesson we’ll discuss some of the ways that you can manage the size of your database tables. Keeping the tables and indexes in your database small can ensure better query performance, more efficient disk utilization, and lower database costs.



Currently the database has a single table named mock.time_series which is just a series of 100,000 random values. SELECT the first 10 rows of time_series and become familiar with the data.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?