Navicat Premium 18: Optimizing PostgreSQL on One Million Orders
Three real-world query patterns. One million synthetic orders. Discover how Navicat's execution plan analysis, visual insights and developer tools supported evidence-driven PostgreSQL optimization.
A shopper returns to an e-commerce site to check whether an order has shipped. The screen needs only the latest 20 orders. But even a small page can make the database do a surprising amount of work. It might apply a date calculation to many candidate rows, sort a large result before keeping the first 20, or walk past thousands of entries just to reach the requested page.
This builds on my order-history indexing and keyset pagination walkthrough. I built a PostgreSQL lab to investigate those three problems and to see which parts of the diagnosis Navicat could make easier. I ran Navicat Premium 18.0.8 Enterprise against PostgreSQL 18.7 in Docker. The table held 1,000,000 synthetic orders. A single customer and a three-day UTC window matched 200,411 orders. In each comparison, I checked that both alternatives returned the same ordered records.
What changed in each query plan
Illustrative execution flows. The captured Navicat plans appear alongside the SQL below.
Watch the 4:17 technical walkthrough
Follow the original SQL, actual Navicat execution plans, and PostgreSQL measurements.
1. Give the index a timestamp range
Before · Apply a date expression
The first query applies a date expression to the stored timestamp. It expresses the right business rule, but PostgreSQL evaluates the date as a separate filter after finding entries for the customer.
SELECT order_id, created_at, status, total_amount
FROM navicat_phase1a.orders
WHERE customer_id = 42
AND DATE(created_at AT TIME ZONE 'UTC') >= DATE '2026-10-30'
AND DATE(created_at AT TIME ZONE 'UTC') < DATE '2026-11-02'
ORDER BY created_at DESC, order_id DESC
LIMIT 20;After · Use direct timestamp bounds
I kept the UTC boundaries and compared the column directly with timestamp constants.
SELECT order_id, created_at, status, total_amount
FROM navicat_phase1a.orders
WHERE customer_id = 42
AND created_at >= TIMESTAMPTZ '2026-10-30 00:00+00'
AND created_at < TIMESTAMPTZ '2026-11-02 00:00+00'
ORDER BY created_at DESC, order_id DESC
LIMIT 20;

Both plans used an Index Only Scan. Navicat made the important distinction visible in the node details. In the first plan, the date appears under Filter. In the second, the timestamp bounds move into Index Cond. That makes the predicate SARGable: PostgreSQL can use the condition to narrow the index scan. The captured node viewer truncates the long condition, while the SQL above shows both boundaries.
Five alternating measured pairs gave medians of 0.083 ms and 0.074 ms. The ranges overlapped (0.072–0.136 ms and 0.058–0.088 ms). The plan changed, but the measurements do not establish a reliable speedup for this workload.
2. Match the index to the order-history query
Query and covering index
The second experiment used the timestamp-range query above unchanged. I compared the plan without the covering index with the plan using this definition.
CREATE INDEX idx_orders_customer_created_id
ON navicat_phase1a.orders (customer_id, created_at DESC, order_id DESC)
INCLUDE (status, total_amount);The leading customer key narrows the search. The next two keys match the requested order, with the order ID breaking timestamp ties. The included columns supply the remaining output fields. PostgreSQL can use an index-only scan when the required data is available from the index and heap visibility permits it.

Without the index, PostgreSQL used a parallel sequential scan, a top-N sort, and Gather Merge before Limit. With it, an Index Only Scan fed Limit directly, and the analyzed run reported zero heap fetches. Both plans returned the same 20 complete records in the same order.
The fresh single-run measurements were 278.733 ms → 0.464 ms (about 99.83% lower execution time), and 9,019 → 4 shared buffer hits. Those buffer hits count accesses to blocks already in PostgreSQL shared buffers. They are not disk reads, and the timings are not production latency guarantees. Visual Explain helped me see where the sort disappeared. PostgreSQL’s analyzed Text Explain supplied the numbers.
3. Start deep pages from a cursor
Before · Skip 100,000 rows
With OFFSET pagination, the database still has to produce and discard the earlier entries even when it uses an index.
SELECT order_id, created_at, status, total_amount
FROM navicat_phase1a.orders
WHERE customer_id = 42
AND created_at >= TIMESTAMPTZ '2026-10-30 00:00+00'
AND created_at < TIMESTAMPTZ '2026-11-02 00:00+00'
ORDER BY created_at DESC, order_id DESC
LIMIT 20 OFFSET 100000;After · Start from the previous page cursor
Keyset pagination passes the final timestamp and order ID from the previous page. With descending order, the next query asks for tuples smaller than that boundary.
SELECT order_id, created_at, status, total_amount
FROM navicat_phase1a.orders
WHERE customer_id = 42
AND created_at >= TIMESTAMPTZ '2026-10-30 00:00+00'
AND created_at < TIMESTAMPTZ '2026-11-02 00:00+00'
AND (created_at, order_id) <
(TIMESTAMPTZ '2026-10-31 06:25:00+00', 10365188)
ORDER BY created_at DESC, order_id DESC
LIMIT 20;

Both approaches used an Index Only Scan in the measured comparison. The scan produced 100,020 rows with OFFSET and 20 with keyset, and both queries returned the same 20 full records in order. Native PostgreSQL execution measured 977.196 ms → 15.566 ms in single runs (about 98.41% lower execution time). Finding the boundary separately took 110.917 ms. A client following a next-page link can reuse the cursor it already has. A client jumping to an arbitrary page needs some way to obtain that boundary.
A backend engineer’s workflow
Suppose a shopper reports that their order history loads slowly. Here is how I would investigate it on a Java and Spring Boot team.
Conceptual backend investigation
- Identify the SQL. Trace the order-history endpoint to its repository query. Record the actual filter, sort and pagination parameters.
- Reproduce in a representative database. Use an appropriate test environment, with comparable data distribution, indexes and statistics.
- Inspect the plan in Navicat. Run the SQL in the editor. Use Explain and Visual Explain to locate extra scanning, sorting or filtering. Use analyzed PostgreSQL output for actual rows and timings.
- Change one thing and compare. Run the revised query or index design, then compare full ordered business records and plan measurements.
- Validate at the application boundary. Test the Spring Boot repository and API with PostgreSQL, tie cases and representative traffic before deployment.
I would bind UTC boundaries as typed parameters and use a half-open interval. For sequential navigation, I would return an opaque cursor containing both the timestamp and order ID and bind it to the same customer scope and filters. I would also measure the write cost of a wider index. The research measured PostgreSQL execution on synthetic data. Java, Spring Boot, REST API latency and production customer experience were outside its scope.
How Navicat supported the investigation
Evidence-backed workflow
- Prepare and run SQL in the editor.
- Inspect text and visual plans to locate database work.
- Run the SQL or index comparison under the same query conditions.
- Check ordered results and actual measurements before drawing a conclusion.
Four Navicat feature areas in practice
What I found valuable about Navicat
I could prepare SQL, inspect the schema and plans, then compare results in the same workflow. Text Explain helped me check the actual work PostgreSQL performed. Visual Explain made it easier to point to the operator that changed when discussing the query with another engineer. SQL suggestions and early warnings helped during authoring. The AI preview gave me a way to inspect sample records before applying them, with SQL validation still needed afterward.
Research limitations and engineering takeaways
This evaluation reinforced a habit I use when investigating slow queries. Start by understanding what the database does, then change one thing and compare the plan and returned records. In these trials, the date condition moved into the index scan, the covering index removed a sort, and the cursor avoided traversing earlier results. PostgreSQL SQL and index changes produced the measured execution differences. Navicat helped me identify the work, explain why the plans changed, and validate the results.
For an order-history endpoint, I would start with the query and its plan, verify that the results match after the change, and then repeat the measurement on data and traffic that resemble the system I intend to ship.
Try Navicat Premium Lite
I evaluated Navicat Premium 18.0.8 Enterprise. Explore Navicat Premium Lite at no cost. The test results above refer to the Enterprise build.
Explore the Research

Disclosure. Navicat provided complimentary evaluation access and offered an annual subscription in connection with publication. The measurements and conclusions below come from my research lab.
Keep exploring
Questions about these trade-offs or a topic for the next article?
Start a conversation ↗Share on LinkedIn ↗Join the conversation
Was this lesson helpful? Leave a like or share a question.
Comments
Related articles
Transactional Outbox in Spring Boot and Kafka: Reliable Order Events
Checkout succeeds, but fulfilment and confirmation never start. Explore the dual-write gap, then recover delivery with a transactional outbox and idempotent consumers.
Java 21Payment Idempotency in Spring Boot: Handling Timeouts and Retries
The gateway authorizes a payment but checkout never receives the response. Explore how stable keys, database uniqueness and reconciliation make retries safer.
Java 21Pessimistic vs Optimistic Locking in Spring Boot: Preventing Inventory Overselling
Two shoppers try to reserve the last item. Compare row locks, version checks, and atomic SQL updates with a four-mode interactive race simulator.