Skip to content

[Bug]: ClickBench Q29 is significantly slower in MatrixOne than DuckDB #27681

Closed as not planned

Description

@daviszhen

Parent issue

This is a sub-issue of #27665: significant gap in ClickBench query performance between MatrixOne and DuckDB.

Summary

ClickBench Q29 shows a significant MatrixOne performance gap against the DuckDB reference. The values below are elapsed seconds. Each result array is the three measurements emitted by the adapter: [run 1, run 2, run 3]; warm median is the median of the available run-2/run-3 values.

Query

SELECT REGEXP_REPLACE(Referer, '^https?://(?:www\.)?([^/]+)/.*$', '\1') AS k, AVG(length(Referer)) AS l, COUNT(*) AS c, MIN(Referer) FROM hits WHERE Referer <> '' GROUP BY k HAVING COUNT(*) > 100000 ORDER BY l DESC LIMIT 25;

Performance comparison

Engine Run 1 Run 2 Run 3 Warm median
MatrixOne 16.000 15.170 15.160 15.165
DuckDB 11.976 1.206 1.130 1.168
  • MatrixOne / DuckDB warm-median ratio: 12.98x
  • Warm-median difference: 13.997 seconds
  • Raw MatrixOne timing array: [16.000, 15.170, 15.160]
  • Raw DuckDB timing array: [11.976, 1.206, 1.130]

Environment and data

MatrixOne measurement:

  • Branch: main
  • Commit: 249a458ba567b26d1818fb0496b449135cb05ef2
  • Hardware: server 129
  • OS: CentOS
  • Dataset: ClickBench hits, 99,997,497 rows
  • MatrixOne raw output: /mnt/fastdata/ClickBench/matrixone/raw_results.md

DuckDB reference:

  • Result file: duckdb/results/20260511/c6a.metal.json
  • Machine label: c6a.metal
  • Result date: 2026-05-11

The two measurements were not collected on the same hardware. The DuckDB value is the latest local c6a.metal reference available; an apples-to-apples rerun on the same server is recommended before assigning a final performance regression magnitude.

Steps to reproduce

  1. Follow the reproduction steps in #27665, including the MatrixOne and DuckDB adapter READMEs:
  2. Use the same hits.tsv.gz dataset for both engines (the adapters support loading the gzip file directly).
  3. In the MatrixOne adapter, run ./benchmark.sh after setting MATRIXONE_HOME, MATRIXONE_DATA_FILE, MATRIXONE_HOST, MATRIXONE_PORT, MATRIXONE_USER, and MATRIXONE_PASSWORD as described in [Bug]: significant gap in clickbench query performance between matrixone and duckdb #27665.
  4. In the DuckDB adapter, run ./benchmark.sh after setting DUCKDB_BIN_PATH, DUCKDB_DB_PATH, and DUCKDB_DATA_PATH as described in the README.
  5. Compare the Q29 entry in queries.sql; run the query three times after loading the data and record elapsed time and whether the query completes successfully.

Notes

  • This query also has a known result-correctness discrepancy in the local validation notes; this sub-issue is for the performance gap only.

Expected behavior

On comparable hardware with the same dataset, MatrixOne should not exhibit a large query-level performance gap for this workload. Please investigate the execution plan, operators, memory use, and any spill or connection/timeout behavior relevant to this query.

Activity

  1. added
    kind/bug
    on Aug 26, 2026
  2. self-assigned this
    on Aug 26, 2026
  3. XuPeng-SH commented on Sep 1, 2026

    @XuPeng-SH
    Contributor

    2026-09-01 candidate diagnosis

    SQL shape: REGEXP_REPLACE-derived VARCHAR group key, AVG/COUNT/MIN, HAVING, then Top25.

    Correctness gate: the recorded result discrepancy must be resolved before performance work; a faster wrong result is not acceptable.

    Concrete execution candidate: the regexp cache already avoids recompiling a constant pattern, but regularReplace currently calls FindAllStringIndex and then, for the common pos=1/occurrence=0 path used by the 3-argument SQL form, calls ReplaceAllLiteralString, causing two regexp traversals. A direct one-pass ReplaceAll fast path is general and small. After that, profile replacement allocation/output bytes and derived-key Group hashing; do not add a URL/domain-specific regexp rewrite.

    Next action: establish a differential result oracle, fix/locate correctness, benchmark one-pass replacement, then profile expression versus Group cost.

    Controls: no/one/many matches, empty string, NULL, invalid pattern, empty captures, backreferences/literal replacement semantics, UTF-8, long strings, and const/non-const pattern.

  4. XuPeng-SH commented on Oct 24, 2026

    @XuPeng-SH
    Contributor

    Tracking consolidated into #27665. The canonical issue now includes this report's independent scope and acceptance criteria. This is administrative consolidation, not a claim that the defect is fixed; the original reproduction and discussion are preserved here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions