Databases 12 min read

How DongSQL’s Syntax Extensions and Concurrency Controls Supercharge E‑commerce Performance

This article provides an in‑depth technical analysis of DongSQL’s kernel redesign—including RETURNING clause, Inventory Hint, CCL concurrency control, Statement Outline, and thread‑pool optimizations—showing how each feature dramatically improves throughput and latency for high‑traffic e‑commerce workloads.

JD Tech Talk
JD Tech Talk
JD Tech Talk
How DongSQL’s Syntax Extensions and Concurrency Controls Supercharge E‑commerce Performance

Introduction

The article provides a technical deep‑dive into DongSQL’s kernel modifications that target large‑scale e‑commerce workloads. It covers three major areas: syntax extensions, concurrency‑control mechanisms, and query‑execution optimizations.

1. Syntax Extension Optimizations

1.1 RETURNING Clause

DongSQL adds a RETURNING clause to all DML statements (INSERT, UPDATE, DELETE, REPLACE). The clause returns the affected rows directly, eliminating the need for a subsequent SELECT and reducing network round‑trips.

-- INSERT returning the generated primary key
INSERT INTO orders (customer_id, order_date) VALUES (1001, NOW()) RETURNING order_id;

-- UPDATE returning changed columns
UPDATE products SET price = price * 1.1 WHERE category = 'electronics' RETURNING product_id, name, old_price, price;

-- DELETE returning deleted rows
DELETE FROM expired_sessions WHERE expire_time < NOW() RETURNING session_id, user_id, expire_time;

Benchmark results (16 concurrent threads) show a 61% increase in TPS and a 44% reduction in latency for fixed‑row updates. Random‑row updates (128 threads) gain 18% TPS, and a 20‑million‑operation test reports a 5‑10% average TPS uplift.

1.2 Hint Syntax Extensions – Inventory Hint

DongSQL introduces a rich hint system. The Inventory Hint is designed for stock‑deduction scenarios and enforces a single‑row impact, automatic commit on success, and rollback on failure.

-- Inventory deduction with safety guarantees
UPDATE /*+ TARGET_AFFECT_ROW(1) COMMIT_ON_SUCCESS ROLLBACK_ON_FAIL */
    inventory SET stock = stock - 5
WHERE product_id = 1001 AND stock >= 5;

In a 16‑thread benchmark the hint yields a 215% TPS improvement over the baseline.

2. Concurrency Control Optimizations

2.1 Concurrency Control Layer (CCL)

CCL provides multi‑dimensional throttling to mitigate hotspot contention in flash‑sale workloads. Three built‑in functions are available: ccl_queue_field(column_name, concurrency) – limits concurrent access per distinct column value. ccl_queue_value(value, concurrency) – throttles a specific data value. ccl_queue_digest(concurrency) – applies a limit to identical SQL digests (patterns).

-- Limit hot product ID 999 to 5 concurrent requests
SELECT /*+ ccl_queue_value(999, 5) */ * FROM products WHERE product_id = 999;

-- Throttle inventory deduction per product ID (8 concurrent requests)
UPDATE /*+ ccl_queue_field(product_id, 8) */ inventory SET stock = stock - 1 WHERE product_id = ?;

-- Digest‑based limit for a common query pattern
SELECT /*+ ccl_queue_digest(10) */ * FROM hot_products WHERE status = 1;

In a 4,096‑thread flash‑sale test, TPS rose from 573 to 1,337 (≈133% increase) and lock contention dropped dramatically.

2.2 Statement Outline and Custom Hint Injection

Statement Outline freezes execution plans for critical SQL, preventing plan instability caused by data changes. DBAs can also inject custom hints for emergency traffic spikes.

-- Freeze plan for a key query
CALL dbms_outln.add_index_outline('test_db', '', 1, 'USE INDEX', 'idx_status', '',
    'SELECT * FROM orders WHERE status = "PAID"');

-- Add a CCL digest hint limiting concurrency to 2
CALL dbms_outln.add_optimizer_outline('test_db', '', 1, '/*+ ccl_queue_digest(2) */',
    'SELECT * FROM orders WHERE customer_id = 1001');

This mechanism guarantees stable performance and enables both manual and automatic throttling.

3. Query Optimization Improvements

3.1 Single‑Point Query Bypass

For primary‑key lookups DongSQL bypasses parts of the SQL execution layer and accesses the storage engine directly. The bypass yields 20‑30% QPS gains in container environments and 28% in bare‑metal setups, with a 20‑28% improvement under CPU‑bound high‑concurrency loads.

3.2 Thread‑Pool Optimization

DongSQL implements an enterprise‑grade thread pool with intelligent scheduling, thread reuse, load balancing, and priority handling. Benchmarks on an 8‑core, 32 GB platform show:

Read‑only workload: 27.6% QPS increase at 32 threads (141,261 vs 110,658).

High‑concurrency read (512 threads): 114% QPS boost (131,939 vs 61,580) and 60% latency reduction (TP99 118.92 ms vs 297.92 ms).

Write‑heavy workload: up to 97% QPS improvement at 512 threads (58,166 vs 29,541).

Mixed read/write (256 threads): 60% QPS increase and 19% latency reduction.

3.3 Additional Execution Engine Optimizations

Further refinements include operator tuning, memory‑management improvements, parallel execution enhancements, and an upgraded buffer‑pool strategy that reduces I/O lock conflicts.

4. Benchmark Summary

Standard OLTP tests (16 CPU, 32 GB RAM, 16 tables × 1 M rows) and e‑commerce‑specific scenarios confirm the cumulative impact of the above optimizations. Key performance gains are:

RETURNING clause – 61% TPS increase (925 → 1,490) for fixed‑row updates.

CCL concurrency control – 133% TPS increase (573 → 1,337) in flash‑sale tests.

Inventory Hint – 215% TPS increase (1,537 → 4,843) for stock‑deduction workloads.

Single‑point query bypass – 28% QPS increase (76,432 → 98,470) for primary‑key lookups.

5. Future Roadmap

Continue extending SQL syntax to meet emerging business requirements.

Integrate machine‑learning models for adaptive execution‑plan selection.

Deepen kernel‑level support and further separate compute from storage for cloud‑native deployments.

Conclusion

Targeted kernel innovations—syntax extensions, sophisticated concurrency controls, and aggressive query optimizations—demonstrate that DongSQL can deliver decisive performance advantages for large‑scale e‑commerce operations while maintaining plan stability and resource efficiency.

SQLConcurrency Controldatabases
JD Tech Talk
Written by

JD Tech Talk

Official JD Tech public account delivering best practices and technology innovation.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.