Sobes.tech
Junior — Middle

What changes occur to the physical placement of data on the disk after deleting a row from a table in a database?

sobes.tech AI

Answer from AI

After deleting a row from a table in a database, the physical location of data on the disk usually does not change immediately. Instead of shifting all subsequent data, the DBMS marks the deleted row as 'deleted' or 'inactive' (for example, by setting a flag or freeing space in a special structure). This is called 'soft deletion'.

The actual freeing of space and data compression occurs during maintenance operations such as:

  • Automatic or manual defragmentation (VACUUM in PostgreSQL, OPTIMIZE TABLE in MySQL)
  • Rebuilding indexes

Thus, deleted records remain on the disk until cleanup is performed, allowing for efficient management of performance and data integrity.

What changes occur to the physical placement of data… - sobes.tech