✔ PASS Vector & Embeddings task_032_Q32_near_duplicate_product_catalog Scaled: 1M+ Records Ordered: Yes

Multi-Merchant Near-Duplicate Catalog Resolution with Price Consistency

Candidate Latency (1M Rows)
495.88 ms
(1.0x slower than golden)
Golden Latency (1M Rows)
477.45 ms
DuckDB in-memory engine
Underlying Data Volume
2,500 rows
175.8 KiB across 1 table
Evaluated Model
gemini-3.8-flash-low
Gen Latency: 14.6s
✔ Correctness Verified on 1M+ Records
Candidate SQL output matches ground truth golden query across all multiset rows and numeric tolerances (tol=1e-3). Zero data skew or anti-patterns detected on full dataset scale.

1. Analytical Significance & What It Means

Scenario & Frontier Trap
Business Scenario & Problem

Marketplaces aggregate catalogs from thousands of sellers. Matching identical items requires high semantic vector similarity AND compatible price bounds (e.g. price within 20%).

⚡ The Frontier Trap (Why LLMs Fail)

Vector similarity alone matches accessories to main products; price filtering alone matches unrelated items.

Prompt / User Request Given to Model
Marketplaces aggregate catalogs from thousands of sellers. Matching identical items requires high semantic vector similarity AND compatible price bounds (e.g. price within 20%).

Execute the required analytical SQL calculation in DuckDB.
Expected output columns: sku_a, merchant_a, title_a, sku_b, merchant_b, title_b, similarity, price_difference_pct.
Results should be ordered as specified.

2. Underlying Tables, Row Counts & Data Volume

1 Tables (2,500 rows • 175.8 KiB)

Production-scale fixtures loaded into the isolated DuckDB sandbox with at least 1,000,000 records per table:

📊 merchant_catalog 2,500 rows 175.8 KiB Data Volume
sku_id (INTEGER) merchant (VARCHAR) title (VARCHAR) price (DECIMAL(10,2)) vector (FLOAT[3])
Data Preview (showing sample rows from 2,500 total rows):
# sku_id merchant title price vector
1 1 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 349.99 [0.95 0.1 0.05]
2 2 Merchant B Sony WH1000XM5 Wireless Headset - Black 339 [0.94 0.12 0.04]
3 3 Merchant C Sony Headphone Replacement Ear Cushions 29.99 [0.88 0.2 0.1 ]
4 3 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 254.02 [0.8532 0.0137 0.0331]
5 4 Merchant B Sony WH1000XM5 Wireless Headset - Black 454.93 [ 0.8974 0.0245 -0.0356]
6 5 Merchant C Sony Headphone Replacement Ear Cushions 253.84 [0.8531 0.0427 0.0635]
7 6 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 314.65 [0.8665 0.0345 0.0183]
8 7 Merchant B Sony WH1000XM5 Wireless Headset - Black 316.15 [0.8668 0.1053 0.081 ]
9 8 Merchant C Sony Headphone Replacement Ear Cushions 309.79 [0.8654 0.0177 0.0892]
10 9 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 132.75 [ 8.265e-01 5.560e-02 -6.000e-04]
11 10 Merchant B Sony WH1000XM5 Wireless Headset - Black 99.34 [ 0.8191 0.068 -0.0093]
12 11 Merchant C Sony Headphone Replacement Ear Cushions 338.05 [ 0.8717 -0.009 0.0663]
13 12 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 477.19 [0.9023 0.0764 0.0418]
14 13 Merchant B Sony WH1000XM5 Wireless Headset - Black 64.87 [0.8115 0.0233 0.0733]
15 14 Merchant C Sony Headphone Replacement Ear Cushions 212.67 [0.8441 0.0943 0.0464]

3. Graphical Query Execution Plan & Cost Bottlenecks

Physical Operator Tree (DuckDB 2.0 Profiler)

Visual flowchart of the physical execution pipeline. Operators with high relative costs (≥ 20% of query runtime or heavy latency) are visually highlighted:

Pipeline Latency Distribution (Total Plan Time: 306.68 ms) Nodes consuming ≥ 20% of query runtime are highlighted with glowing borders
📐 PROJECTION 1.5%
Latency: 4.60 ms
Rows In/Out: 323,302
Data Vol: 25.90 MB
📁 Projections: ['CAST(#0 AS INTEGE...
⏳ ORDER_BY 🔥 25.8% Cost
Latency: 79.08 ms
Rows In/Out: 323,302
Data Vol: 24.67 MB
⚠️ Heavy Execution Bottleneck (25.8% of query runtime)
📐 PROJECTION 3.0%
Latency: 9.23 ms
Rows In/Out: 323,302
Data Vol: 24.67 MB
📁 Projections: ['CAST(#0 AS SMALLI...
📐 PROJECTION 12.3%
Latency: 37.57 ms
Rows In/Out: 323,302
Data Vol: 25.90 MB
📁 Projections: ['sku_a', 'merchant...
⚡ PIECEWISE_MERGE_JOIN 🔥 57.4% Cost
Latency: 175.97 ms
Rows In/Out: 323,302
Data Vol: 34.53 MB
⚠️ Heavy Execution Bottleneck (57.4% of query runtime)
🔍 TABLE_SCAN 0.0%
Latency: 0.11 ms
Rows In/Out: 2,500
Data Vol: 0.13 MB
📁 memory.main.merchant_catalog
🔍 TABLE_SCAN 0.0%
Latency: 0.13 ms
Rows In/Out: 2,500
Data Vol: 0.13 MB
📁 memory.main.merchant_catalog
Operator Cost % Latency Processed Rows Data Volume Details / Table Status
PIECEWISE_MERGE_JOIN 57.4% 175.97 ms 323,302 34.53 MB - 🔥 BOTTLENECK
ORDER_BY 25.8% 79.08 ms 323,302 24.67 MB - 🔥 BOTTLENECK
PROJECTION 12.3% 37.57 ms 323,302 25.90 MB Projections: ['sku_a', 'merchant_a', 'title_a', Normal
PROJECTION 3.0% 9.23 ms 323,302 24.67 MB Projections: ['CAST(#0 AS SMALLINT)', '__interna Normal
PROJECTION 1.5% 4.60 ms 323,302 25.90 MB Projections: ['CAST(#0 AS INTEGER)', '__internal Normal
TABLE_SCAN 0.0% 0.13 ms 2,500 0.13 MB memory.main.merchant_catalog Normal
TABLE_SCAN 0.0% 0.11 ms 2,500 0.13 MB memory.main.merchant_catalog Normal

4. Queries Executed (Candidate vs Golden Ground Truth)

Beautified & Syntax Highlighted
Candidate SQL Executed by gemini-3.8-flash-low (Runtime on 1M Rows: 495.88 ms)
SELECT a.sku_id AS sku_a,
       a.merchant AS merchant_a,
       a.title AS title_a,
       b.sku_id AS sku_b,
       b.merchant AS merchant_b,
       b.title AS title_b,
       round(array_cosine_similarity(a.vector, b.vector), 4) AS similarity,
       round(abs(a.price - b.price) / a.price * 100, 1) AS price_difference_pct
FROM merchant_catalog a
JOIN merchant_catalog b ON a.sku_id < b.sku_id
AND a.merchant != b.merchant
AND array_cosine_similarity(a.vector, b.vector) >= 0.90
AND abs(a.price - b.price) <= (0.20 * a.price)
ORDER BY similarity DESC;
Golden Reference Ground Truth SQL (Runtime on 1M Rows: 477.45 ms)
-- Match identical product listings across merchants (high similarity + price within 20%)

SELECT a.sku_id AS sku_a,
       a.merchant AS merchant_a,
       a.title AS title_a,
       b.sku_id AS sku_b,
       b.merchant AS merchant_b,
       b.title AS title_b,
       round(array_cosine_similarity(a.vector, b.vector), 4) AS similarity,
       round(abs(a.price - b.price) / a.price * 100, 1) AS price_difference_pct
FROM merchant_catalog a
JOIN merchant_catalog b ON a.sku_id < b.sku_id
AND a.merchant != b.merchant
AND array_cosine_similarity(a.vector, b.vector) >= 0.90
AND abs(a.price - b.price) <= (0.20 * a.price)
ORDER BY similarity DESC;
DuckDB Fixture Setup DDL & Data Population
CREATE TABLE merchant_catalog (sku_id INT, merchant VARCHAR, title VARCHAR, price decimal(10, 2),
                                                                                  vector FLOAT[3]);


INSERT INTO merchant_catalog
VALUES (1, 'Merchant A', 'Sony WH-1000XM5 Noise-Cancelling Headphones', 349.99, [0.95, 0.1, 0.05]::FLOAT[3]),
       (2, 'Merchant B', 'Sony WH1000XM5 Wireless Headset - Black', 339.00, [0.94, 0.12, 0.04]::FLOAT[3]),
       (3, 'Merchant C', 'Sony Headphone Replacement Ear Cushions', 29.99, [0.88, 0.2, 0.1]::FLOAT[3]);

5. Query Results & Expected Ground Truth

Tabular Comparison
Actual Candidate Output (323,302 rows × 8 cols)
# sku_a merchant_a title_a sku_b merchant_b title_b similarity price_difference_pct
1 56 Merchant C Sony Headphone Replacement Ear Cushions 67 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 4
2 7 Merchant B Sony WH1000XM5 Wireless Headset - Black 81 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 6.7
3 112 Merchant B Sony WH1000XM5 Wireless Headset - Black 116 Merchant C Sony Headphone Replacement Ear Cushions 1 11.7
4 8 Merchant C Sony Headphone Replacement Ear Cushions 118 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 14.3
5 1 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 119 Merchant C Sony Headphone Replacement Ear Cushions 1 2.6
6 115 Merchant B Sony WH1000XM5 Wireless Headset - Black 125 Merchant C Sony Headphone Replacement Ear Cushions 1 15.5
7 65 Merchant C Sony Headphone Replacement Ear Cushions 138 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 0
8 18 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 142 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 10.7
9 90 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 142 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 15.7
10 133 Merchant B Sony WH1000XM5 Wireless Headset - Black 143 Merchant C Sony Headphone Replacement Ear Cushions 1 6.2
11 3 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 145 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18
12 66 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 149 Merchant C Sony Headphone Replacement Ear Cushions 1 2.1
13 112 Merchant B Sony WH1000XM5 Wireless Headset - Black 149 Merchant C Sony Headphone Replacement Ear Cushions 1 13.1
14 127 Merchant B Sony WH1000XM5 Wireless Headset - Black 153 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 9.1
15 71 Merchant C Sony Headphone Replacement Ear Cushions 157 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18.7
16 144 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 169 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 15.5
17 63 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 182 Merchant C Sony Headphone Replacement Ear Cushions 1 10.9
18 13 Merchant B Sony WH1000XM5 Wireless Headset - Black 186 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 18.8
19 84 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 191 Merchant C Sony Headphone Replacement Ear Cushions 1 5.7
20 74 Merchant C Sony Headphone Replacement Ear Cushions 204 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 8.8
21 162 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 211 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 10.5
22 177 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 211 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18.2
23 123 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 214 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 7.8
24 126 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 218 Merchant C Sony Headphone Replacement Ear Cushions 1 17
25 79 Merchant B Sony WH1000XM5 Wireless Headset - Black 219 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 9.8
Showing first 25 of 323,302 total rows.
Expected Golden Output (323,302 rows × 8 cols)
# sku_a merchant_a title_a sku_b merchant_b title_b similarity price_difference_pct
1 56 Merchant C Sony Headphone Replacement Ear Cushions 67 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 4
2 7 Merchant B Sony WH1000XM5 Wireless Headset - Black 81 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 6.7
3 112 Merchant B Sony WH1000XM5 Wireless Headset - Black 116 Merchant C Sony Headphone Replacement Ear Cushions 1 11.7
4 8 Merchant C Sony Headphone Replacement Ear Cushions 118 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 14.3
5 1 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 119 Merchant C Sony Headphone Replacement Ear Cushions 1 2.6
6 115 Merchant B Sony WH1000XM5 Wireless Headset - Black 125 Merchant C Sony Headphone Replacement Ear Cushions 1 15.5
7 65 Merchant C Sony Headphone Replacement Ear Cushions 138 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 0
8 18 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 142 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 10.7
9 90 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 142 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 15.7
10 133 Merchant B Sony WH1000XM5 Wireless Headset - Black 143 Merchant C Sony Headphone Replacement Ear Cushions 1 6.2
11 3 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 145 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18
12 66 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 149 Merchant C Sony Headphone Replacement Ear Cushions 1 2.1
13 112 Merchant B Sony WH1000XM5 Wireless Headset - Black 149 Merchant C Sony Headphone Replacement Ear Cushions 1 13.1
14 127 Merchant B Sony WH1000XM5 Wireless Headset - Black 153 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 9.1
15 71 Merchant C Sony Headphone Replacement Ear Cushions 157 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18.7
16 144 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 169 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 15.5
17 63 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 182 Merchant C Sony Headphone Replacement Ear Cushions 1 10.9
18 13 Merchant B Sony WH1000XM5 Wireless Headset - Black 186 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 18.8
19 84 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 191 Merchant C Sony Headphone Replacement Ear Cushions 1 5.7
20 74 Merchant C Sony Headphone Replacement Ear Cushions 204 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 8.8
21 162 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 211 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 10.5
22 177 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 211 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 18.2
23 123 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 214 Merchant B Sony WH1000XM5 Wireless Headset - Black 1 7.8
24 126 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 218 Merchant C Sony Headphone Replacement Ear Cushions 1 17
25 79 Merchant B Sony WH1000XM5 Wireless Headset - Black 219 Merchant A Sony WH-1000XM5 Noise-Cancelling Headphones 1 9.8
Showing first 25 of 323,302 total rows.
← Prev: Semantic Deduplication of... ⊞ Back to Benchmark Dashboard Next: ColBERT Multi-Vector Late... →