FAQ: PostgreSQL Database Maintenance - Vacuum Full

This community-built FAQ covers the “Vacuum Full” exercise from the lesson “PostgreSQL Database Maintenance”.

Paths and Courses
This exercise can be found in the following Codecademy content:

(Beta) CS103: Databases

FAQs on the exercise Vacuum Full

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in Language Help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to Language Help and Tips and Resources. If you are wanting feedback or inspiration for a project, check out Projects.

Looking for motivation to keep learning? Join our wider discussions in Community

Learn more about how to use this guide.

Found a bug? Report it online, or post in Bug Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

SELECT pg_size_pretty(
    pg_total_relation_size('mock.orders')
) as total_size;
-- 1024kb size

select relname, n_live_tup, n_dead_tup , last_vacuum
from pg_catalog.pg_stat_all_tables
where relname = 'orders';
-- 7500 live, 7500 dead

VACUUM FULL mock.orders;

SELECT pg_size_pretty(
    pg_total_relation_size('mock.orders')
) as total_size;
-- 504kb total size

select relname, n_live_tup, n_dead_tup , last_vacuum
from pg_catalog.pg_stat_all_tables
where relname = 'orders';
-- still returns 7500, 7500..?

So I’m confused at what actually went on in this lesson, since the info clearly states that “VACUUM FULL which rewrites all the data from a table into a “new” location on disk and only copies the required data (excluding dead tuples)”

Yet my copied codeblock demonstrates that the dead tuples are all still present in the example workspace when I rechecked after the VACCUM FULL (and also doesn’t seem to recognise the fact that a vacuum took place)

…what?

If the new VACUUM’ed data is in a new table, how do we get to said new table?

1 Like