top of page

Does a Gap in Database IDs Prove That Records Were Deleted?

Oct 25
3 min read
Database ID Gaps: Check Before Inferring Deletion: Observe the ID gap; Check committed evidence; Record the supported conclusion.

An export contains record IDs 701 and 703, but no 702. Someone concludes that a record was deleted and asks the team to restore it. That conclusion is premature. An identifier gap tells you which number is absent from the export; it does not tell you why.


Generated identifiers serve a different purpose from a complete record of business events. Investigate the mechanism that assigns them and the evidence available for the missing number before changing data or accusing a process of losing records.


Confirm which kind of identifier you are examining


Find the field definition. It may be a database sequence value, an externally supplied reference, a human-assigned code, or a value transformed during export. These mechanisms have different properties.


This guide concerns PostgreSQL sequence-generated values. It does not establish a policy for document numbering, legal records, or any system that has a separate requirement for gapless numbering. Such requirements need their own verified design.


Understand a sequence's relevant limitation


PostgreSQL documents that values obtained from nextval are not reclaimed when the calling transaction aborts. It also describes conflict-handling paths that can consume a value without inserting the proposed row. A sequence therefore does not provide gapless numbering.


These facts provide possible explanations for a gap. They do not prove which explanation applies to a particular system. A deletion could still have happened, and an export filter could also have hidden an existing record.


An illustrative aborted insert


Suppose a test transaction obtains 702 while preparing a new project record. The transaction later aborts. A subsequent successful insert receives 703. The committed project table can contain 701 and 703 without ever having contained a committed project row numbered 702.


Treat this as a mechanism demonstration, not a reconstruction of your incident. To establish the actual sequence of events, use evidence retained by the application and database under your normal operational arrangements.


Trace the gap through the reporting path


First check whether the exported population matches the question. Date ranges, project status filters, access restrictions, and joins can all affect which records appear. Compare the export to the intended authorized source population using the same snapshot or a documented observation time.


Next inspect available evidence for the identifier: successful creation records, transaction outcomes, authorized deletion history, or application logs. Note which evidence is unavailable. An absent log entry may reflect retention or logging scope rather than proof that an event never occurred.


Keep a compact investigation record


Record the identifier, the observation time, the source query or export definition, and the evidence checked. Separate confirmed facts from possible explanations.


A useful conclusion might say that 702 is absent from the current project table and the export, but retained evidence does not establish whether it was ever committed. Another might identify a logged aborted operation. Both are more accurate than treating the gap itself as a deletion event.


Avoid repairs that only improve appearance


Do not renumber existing records to make the series look continuous. References elsewhere may rely on those identifiers, and a visually tidy sequence does not repair an unknown history.


Likewise, do not create a placeholder record merely to occupy an unused number. That introduces a business object that may never have existed. Any recovery should follow evidence of a specific missing object and an authorized restoration process.


Improve future evidence deliberately


If the organization needs to reconcile created and removed projects, define the events that must be recorded and the retention needed for that reconciliation. Keep that design separate from the identifier generator.


The completion criterion is a supported explanation or a clearly bounded uncertainty, not a continuous list of numbers. A gap is a starting point for investigation. The evidence around committed business events determines what you can responsibly conclude.


Continue with Why a Customer Identifier Should Not Automatically Become a Number for the related planning decision.


The published FutureOS introduction describes the project as being in prelaunch. Use this guide to prepare a concrete project discussion; it does not announce an available FutureOS feature.



Prepared with AI assistance. Primary sources checked on October 25, 2026. Examples and procedures are illustrative editorial guidance, not FutureOS product announcements or an independently reviewed assessment.

Recent Posts

See All

Comments


bottom of page