Repository navigation
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide
|
yuseok89
left a comment
There was a problem hiding this comment.
Welcome, and thanks for this! Nice catch on the collation order. I left one small suggestion inline.
| # Keep this fallback scoped to Dag lists; the shared matcher is tracked in | ||
| # https://github.com/apache/airflow/issues/74551 |
There was a problem hiding this comment.
The Dag filter on the XCom list searches the same Dag display name, and it looks like it would still miss 카페매출집계 when searching 카페, since it keeps the default prefix matcher. Would it make sense to cover it in this PR too?
There was a problem hiding this comment.
I missed that one, thanks for catching it! I've added the implementation and test coverage.
If I get a chance to contribute to Airflow again, I'll be a bit more thorough next time 🙂
|
This one feels a bit odd to be fixing client site -- I would have expected the fix to this to be to change the database's collation?
Can you explain that a bit more? I don't quite understand what it means. |
I didn't go with changing the collation because it would require existing installations to change their database setup, and it could also affect sorting and comparisons elsewhere. That said, I think the shared filter you suggested on Slack is the better place for this. Fixing it there means we don't need to add
The filter builds the upper bound by bumping the last character to the next Unicode code point. For name >= '카페' AND name < '카펙'That works if strings are compared by code point, but Postgres compares them using the collation, and the two orders don't always match. On PostgreSQL 16.15: SELECT '카페매출집계' < '카펙' COLLATE "en_US.utf8"; -- false
SELECT '카페매출집계' < '카펙' COLLATE "C"; -- trueSo with If that sounds reasonable, I'll update the PR to move the fix into the shared filter, and would appreciate a look once it's up. Dropping the bounds can lose the range scan on indexed columns, so I'll include the performance numbers too. Let me know if you think the collation approach would fit better. Drafted-by: Codex (GPT-6); reviewed by ehddnr301 before posting |
|
Oof.
That sounds super fragile when dealing with anything unicode related. You probably have more experience of this than me -- if you tell me this approach as implemented in this PR is safe I'll believe you. |
For non-ASCII prefixes this PR doesn't bump at all, it just checks You were right about it being fragile though, and it's not just Unicode. With an ICU Czech collation, where So I'd keep this PR as is since it fixes the common case, and sort out the shared filter in #74551, which I opened for it. I'll add the Czech case there too. |
The Dag-specific subclass left every other *_prefix_pattern filter with the same missed matches, and the fix in the shared matcher turned out to be a single condition.
|
@ashb, I moved the fix into the common prefix-search code to find the missing non-ASCII matches. I thought a minimal change would leave fewer things to consider when revisiting the implementation later. The missing Search results and timing These are
The old zero counts are missed matches. They do not represent a faster query returning the same results. These timings exclude HTTP overhead; regressions for other terms and collations are included below. I would fix the search failures here and handle further performance work in follow-up PRs. The Experiment setup and tables (2–49-character terms)Benchmark These tables show four 2–49-character terms from the PostgreSQL 16 measurements at 1k, 10k, 100k, 200k and 1m rows. They cover two collations and both an indexed column and a CASE expression like Dag display names. 90% of the synthetic values contain non-ASCII characters (e.g. These are times after the change. The first two searches use the en_US.utf8 indexed column; the last column is the slowest result for the four terms shown, across both collations and query shapes.
Warm cache, one warmup and three measured runs per query. Times sum the medians of count and The four search terms shown
en_US.utf8 / indexed column: 20 comparisons
en_US.utf8 / display-name CASE: 20 comparisons
C / indexed column: 20 comparisons
C / display-name CASE: 20 comparisons
Match counts are totals before LIMIT. “Miss” marks an incorrect result; those faster queries are not equivalent-result performance improvements. Earlier 200k-row benchmark: all before/after results across three databases Different dataset, warm cache, sum of medians from 21 runs of count and ORDER BY name LIMIT 50. This is separate from the size matrix. Match counts follow the earlier correctness checks and the preserved data generator.
Drafted-by: Codex (GPT-6); reviewed by ehddnr301 before posting |
|
250ms across 1 m rows is "slow bit acceptable" territory. Could you show an explain analyse output for some of these larger cases please? |
|
@ashb, here are the EXPLAIN ANALYZE outputs for the 1m-row cases! Prefix search on 1m rowsWith the same setup, the 1m-row Count uses a full table scan. The page query uses the primary-key index for
1m rows: the ~250 ms 카페 case — SQL / EXPLAIN ANALYZESetup: PostgreSQL 16.15 / Total-count query EXPLAIN (ANALYZE, BUFFERS)
SELECT count(*) AS count_1
FROM (
SELECT long_prefix_probe.id AS id
FROM long_prefix_probe
WHERE
long_prefix_probe.name_locale >= '카페'
AND substr(long_prefix_probe.name_locale, 1, 2) = '카페'
) AS anon_1;Page query EXPLAIN (ANALYZE, BUFFERS)
SELECT long_prefix_probe.id
FROM long_prefix_probe
WHERE
long_prefix_probe.name_locale >= '카페'
AND substr(long_prefix_probe.name_locale, 1, 2) = '카페'
ORDER BY long_prefix_probe.id
LIMIT 100;The 49-character termThe 49-character search uses the same scan types and spends more time in the scan nodes. 1m rows: 49-character term — SQL / EXPLAIN ANALYZETotal-count query EXPLAIN (ANALYZE, BUFFERS)
SELECT count(*) AS count_1
FROM (
SELECT long_prefix_probe.id AS id
FROM long_prefix_probe
WHERE
long_prefix_probe.name_locale >=
'카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'
AND substr(long_prefix_probe.name_locale, 1, 49) =
'카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'
) AS anon_1;Page query EXPLAIN (ANALYZE, BUFFERS)
SELECT long_prefix_probe.id
FROM long_prefix_probe
WHERE
long_prefix_probe.name_locale >=
'카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'
AND substr(long_prefix_probe.name_locale, 1, 49) =
'카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'
ORDER BY long_prefix_probe.id
LIMIT 100;Drafted-by: Codex (GPT-6.1), Claude (5.5); reviewed by ehddnr301 before posting |
UI API measurementsI called
The earlier TEMP-table run took about 2 s for that term’s two DB queries. Those scans were serial; all three searches here used Setup and execution plansPostgreSQL 16.15 / One warmup, then three measured runs; the table shows medians. DB totals sum the count and page query medians. Local Table layout, ordering and page size also changed from the TEMP benchmark, so this comparison does not isolate parallel execution. The TEMP ASCII query used a name index; the display-name CASE query scanned the full table for ASCII too. 49-character term:
|
|
Hi @ashb, I've added the query plans and UI API timings above. Could you take another look when you have a chance? Thanks! |
Searching the Dag list for
카페can omit카페매출집계on PostgreSQL with libcen_US.utf8collation. The code-point-derived upper bound does not follow the database's collation order.Use substring equality for non-ASCII display-name prefixes. ASCII prefixes and other prefix filters retain their existing behavior. Update the API description to document the exception.
Before / After
Searching for
카페returns no results before the fix and correctly returns카페매출집계after the fix.Captured from the local UI using the same synthetic data and PostgreSQL
en_US.utf8collation. The before capture uses the original range matcher; the after capture uses substring equality.In a warm-cache benchmark with 20,000 synthetic Dags, the sum of median count and list query times increased by approximately 3–5 ms. This avoids database-specific collation handling.
Validation:
The remaining shared prefix matcher work is tracked separately.
related: #74551
Was generative AI tooling used to co-author this PR?
Generated-by: Codex (GPT-6) following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.Drafted-by: Codex (GPT-6)