A database upgrade can look simple on paper: install the new version, migrate the schema, run the application, and verify that everything works.
Performance upgrades are rarely that simple.
A new PostgreSQL major version can change query-planner behavior, which means the same SQL generated by an EF Core application may produce a different execution plan after an upgrade. Sometimes that change improves performance. Sometimes it has little measurable effect. In certain workloads, a different plan can even expose a regression that was not visible on the previous version.
PostgreSQL 19 is currently in beta, with Beta 2 released on July 16, 2026. The PostgreSQL project specifically encourages developers to test their typical workloads against the beta before the final release, while also advising against using beta releases in production. The project currently plans PostgreSQL 19 for September 2026.
That makes this a good time to build a controlled benchmark with a real .NET application rather than relying on feature lists or synthetic database tests.
This article shows how to compare PostgreSQL planner behavior for an EF Core workload and identify meaningful differences in execution plans, latency, reads, and resource consumption.
Why Planner Changes Matter to EF Core Applications
EF Core does not execute LINQ directly against PostgreSQL.
The basic flow looks like this:
LINQ Query
|
v
EF Core Query Translation
|
v
Generated SQL
|
v
PostgreSQL Parser
|
v
Query Planner / Optimizer
|
v
Execution Plan
|
v
Query Result
The application may generate exactly the same SQL against two PostgreSQL major versions.
The planner can still choose different execution strategies.
For example, a query might use:
Index Scan
on one version and:
Bitmap Heap Scan
-> Bitmap Index Scan
on another.
The difference is important because query planning depends on statistics, estimated row counts, available indexes, table size, configuration, and planner behavior.
PostgreSQL's documentation describes the planner as the component responsible for considering possible execution strategies and selecting a plan based on estimated costs.
That means a database upgrade should be benchmarked using application-shaped queries.
What PostgreSQL 19 Beta Means for This Benchmark
There is an important distinction between testing PostgreSQL 19 Beta and benchmarking a final production release.
PostgreSQL explicitly states that beta and release-candidate versions are intended for testing and are not recommended for production systems. Behavior and implementation details can still change before the final release.
Therefore, this benchmark should answer questions such as:
Does the planner choose different plans?
Are those plans better for our workload?
Which queries change?
Does execution time improve or regress?
Are estimated and actual row counts significantly different?
Do index usage patterns change?
Does EF Core application latency change?
It should not be presented as a final PostgreSQL 19 performance verdict.
Build a Representative EF Core Workload
Start with an application model that resembles a typical business API.
For example:
public class Order
{
public long Id { get; set; }
public long CustomerId { get; set; }
public DateTime CreatedAt { get; set; }
public string Status { get; set; } = string.Empty;
public decimal TotalAmount { get; set; }
}
The corresponding DbContext can be configured normally:
public class AppDbContext : DbContext
{
public DbSet<Order> Orders => Set<Order>();
public AppDbContext(
DbContextOptions<AppDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Order>()
.HasIndex(x => new
{
x.CustomerId,
x.CreatedAt
});
modelBuilder.Entity<Order>()
.HasIndex(x => new
{
x.Status,
x.CreatedAt
});
}
}
The important point is that the benchmark should use realistic indexes.
Removing indexes simply to make the planner comparison more dramatic produces results that may not represent a real application.
Create a Representative Query
Consider an API that retrieves recent completed orders for a customer:
var orders = await db.Orders
.AsNoTracking()
.Where(x =>
x.CustomerId == customerId &&
x.Status == "Completed" &&
x.CreatedAt >= startDate)
.OrderByDescending(x => x.CreatedAt)
.Take(100)
.ToListAsync();
This query contains several planner-relevant characteristics:
Equality filtering
Multiple predicates
Date filtering
Ordering
Limiting results
Composite indexes
Potentially large tables
These characteristics make it more useful for an upgrade benchmark than a trivial SELECT * query.
Capture the SQL Generated by EF Core
Before comparing PostgreSQL versions, capture the SQL generated by the same EF Core version.
You can inspect generated SQL using:
var query = db.Orders
.AsNoTracking()
.Where(x =>
x.CustomerId == customerId &&
x.Status == "Completed" &&
x.CreatedAt >= startDate)
.OrderByDescending(x => x.CreatedAt)
.Take(100);
Console.WriteLine(query.ToQueryString());
The important rule is consistency.
Use the same:
EF Core version
Provider version
Application code
Query
Parameters
Schema
Indexes
Dataset
The PostgreSQL server version should be the primary variable being changed.
Otherwise, it becomes difficult to determine what caused a performance difference.
Use EXPLAIN ANALYZE
Once you have the generated SQL, run it through PostgreSQL's execution-plan tools.
A useful starting point is:
EXPLAIN (ANALYZE, BUFFERS)
SELECT
"Id",
"CustomerId",
"CreatedAt",
"Status",
"TotalAmount"
FROM "Orders"
WHERE "CustomerId" = 1001
AND "Status" = 'Completed'
AND "CreatedAt" >= TIMESTAMP '2026-01-01'
ORDER BY "CreatedAt" DESC
LIMIT 100;
EXPLAIN shows the planner's selected execution strategy.
ANALYZE actually executes the query and provides runtime information.
BUFFERS adds information about buffer activity, which can help explain why two plans with similar execution times may have different I/O behavior.
Do not run EXPLAIN ANALYZE blindly against destructive statements. For benchmark work, begin with read-only queries.
What to Compare Between Versions
The most useful comparison is not simply:
PostgreSQL 18 = 14 ms
PostgreSQL 19 = 11 ms
That number alone does not explain why the result changed.
Compare the plans.
| Metric | PostgreSQL Version A | PostgreSQL Version B | Why It Matters |
|---|---|---|---|
| Planning Time | Measure | Measure | Indicates planning overhead |
| Execution Time | Measure | Measure | Primary runtime metric |
| Rows Returned | Measure | Measure | Confirms equivalent results |
| Shared Buffers Hit | Measure | Measure | Indicates cached page activity |
| Shared Buffers Read | Measure | Measure | Indicates physical reads |
| Scan Type | Record | Record | Reveals plan changes |
| Estimated Rows | Record | Record | Shows planner estimates |
| Actual Rows | Record | Record | Shows estimation accuracy |
| Join Strategy | Record | Record | Important for relational workloads |
| Sort Strategy | Record | Record | Useful for ordered queries |
Join the conversation! Your thoughts help the community grow.