1. [Home](<https://delaparra-services.nl/>) 
1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) 
1. [phantom read](<https://delaparra-services.nl/knowledge-hub/phantom-read>)

  

Category: SQL 

# phantom read

  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    

## What is phantom read?

 

phantom read: Re-running a range query returns new rows that another committed transaction inserted in between. A phantom read happens when a transaction runs the same range query twice and the second time sees extra rows, because another transaction inserted and committed them in between. Counting orders above 100 euros returns 42, then 43 a moment later inside the same transaction. The existing rows did not change; a new one appeared.

 

Definition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)

 

## Frequently asked questions about phantom read

  

### What should you keep in mind with phantom read?

 

Whether this can happen depends on the isolation level. The ` SERIALIZABLE ` level prevents it everywhere. PostgreSQL's ` REPEATABLE READ ` also prevents it, and MySQL's InnoDB avoids it for normal reads in its default level through snapshots and gap locks. For most applications this is rarely a problem. It matters for checks like "is this time slot still free", where a unique constraint or a lock is the reliable way to prevent double bookings.

    

### What does an example of phantom read look like?

 

```
SELECT COUNT(*) FROM orders WHERE total > 100; -- run twice: count grows because a row was inserted
```

 

## At a glance

   CategorySQL Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026

 

## More SQL terms

 

- [LEFT (OUTER) JOIN](<https://delaparra-services.nl/knowledge-hub/left-outer-join>) 
- [OVER](<https://delaparra-services.nl/knowledge-hub/over>) 
- [PARTITION BY](<https://delaparra-services.nl/knowledge-hub/partition-by>) 
- [RANK / DENSE\_RANK](<https://delaparra-services.nl/knowledge-hub/rank-dense-rank>) 
- [READ COMMITTED](<https://delaparra-services.nl/knowledge-hub/read-committed>) 
- [READ UNCOMMITTED](<https://delaparra-services.nl/knowledge-hub/read-uncommitted>)

 

[All terms starting with P](<https://delaparra-services.nl/knowledge-hub#letter-p>)

 

## Skills

 

- ### Concurrency pitfalls

 

Use when code runs things at the same time - threads, async/await, queues and workers, parallel requests, cron jobs, webhooks that retry - or when a bug only happens "sometimes" or under load. Covers race conditions, deadlocks, mutexes/locks, atomic operations, idempotency, message queues and backpressure, with Laravel and database examples.

 [View skill](<https://delaparra-services.nl/skills/concurrency-pitfalls>) [Download zip](<https://delaparra-services.nl/skills/concurrency-pitfalls/download>) 
- ### SQL Optimization Patterns

 

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

 [View skill](<https://delaparra-services.nl/skills/sql-optimization-patterns>) [Download zip](<https://delaparra-services.nl/skills/sql-optimization-patterns/download>) 
- ### Laravel Database Optimization

 

Laravel database optimization patterns. Use when writing Eloquent queries, creating migrations, configuring caching, debugging slow queries, or optimizing database performance. Triggers on tasks involving N+1 queries, indexing, Redis caching, pagination, or database transactions.

 [View skill](<https://delaparra-services.nl/skills/laravel-database-optimization>) [Download zip](<https://delaparra-services.nl/skills/laravel-database-optimization/download>)

 [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/phantom-read/skills.zip>)

 

## Manuals

 

- [Writing SQL queries and migrations](<https://delaparra-services.nl/manuals/sql-queries-en-migraties>)

 

## Related services

 

- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)

Perhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet. 
- [AI code review](<https://delaparra-services.nl/services#service-05>)

When you push your new change, I will review your code, help your agent avoid the same mistake again, and get your app ready for deployment.

 

## Need any help?

 

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.

  [Get in touch](<https://delaparra-services.nl/availability>)

[HTML version](https://delaparra-services.nl/knowledge-hub/phantom-read)
