Skip to content

Fix Unicode prefix matching in the Dag list - #74552

Open
ehddnr301 wants to merge 8 commits into
apache:mainfrom
ehddnr301:fix-unicode-prefix-search
Open

ehddnr301 wants to merge 8 commits into
apache:mainfrom
ehddnr301:fix-unicode-prefix-search

Conversation

@ehddnr301

@ehddnr301 ehddnr301 commented Oct 11, 2026 •

Copy link
Copy Markdown

Searching the Dag list for 카페 can omit 카페매출집계 on PostgreSQL with libc en_US.utf8 collation. 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.

AS-IS TO-BE
Before: no matching Dags After: matching Dag found

Captured from the local UI using the same synthetic data and PostgreSQL en_US.utf8 collation. 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:

  • Core API/Always and common.compat/FAB tests, with and without DB access.
  • PostgreSQL 16 regression and API cases: 9 passed.
  • UI tests: 1,865 passed; SimpleAuth UI: 1 passed.
  • Generated Python API client tests: 360 passed.
  • Pre-commit/manual checks and affected documentation builds passed.

The remaining shared prefix matcher work is tracked separately.

related: #74551


Was generative AI tooling used to co-author this PR?
  • Yes — Codex (GPT-6); Claude assisted with the initial investigation.

Generated-by: Codex (GPT-6) following the guidelines


  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {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)

@boring-cyborg

boring-cyborg Bot commented Oct 11, 2026

Copy link
Copy Markdown

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
Here are some useful points:

  • Pay attention to the quality of your code (ruff, mypy and type annotations). Our prek-hooks will help you with that.
  • In case of a new feature add useful documentation (in docstrings or in docs/ directory). Adding a new operator? Check this short guide Consider adding an example Dag that shows how users should use it.
  • Consider using Breeze environment for testing locally, it's a heavy docker but it ships with a working Airflow and a lot of integrations.
  • Be patient and persistent. It might take some time to get a review or get the final approval from Committers.
  • Please follow ASF Code of Conduct for all communication including (but not limited to) comments on Pull Requests, Mailing list and Slack.
  • Be sure to read the Airflow Coding style.
  • Always keep your Pull Requests rebased, otherwise your build might fail due to changes not related to your commits.
    Apache Airflow is a community-driven project and together we are making it better 🚀.
    In case of doubts contact the developers at:
    Mailing List: [email protected]
    Slack: https://s.apache.org/airflow-slack

@yuseok89 yuseok89 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welcome, and thanks for this! Nice catch on the collation order. I left one small suggestion inline.

Comment on lines +68 to +69
# Keep this fallback scoped to Dag lists; the shared matcher is tracked in
# https://github.com/apache/airflow/issues/74551

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 🙂

@ashb

ashb commented Oct 13, 2026

Copy link
Copy Markdown
Member

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?

The code-point-derived upper bound does not follow the database's collation order.

Can you explain that a bit more? I don't quite understand what it means.

@ehddnr301

ehddnr301 commented Oct 13, 2026 •

Copy link
Copy Markdown
Author

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?

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 COLLATE "C" to each affected query, and the filter returns correct results regardless of the database's collation.

Can you explain that a bit more? I don't quite understand what it means.

The filter builds the upper bound by bumping the last character to the next Unicode code point. For 카페, that gives:

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";           -- true

So with en_US.utf8, 카페매출집계 falls outside the range even though it starts with 카페. Since the conditions are ANDed, the substring check can't bring it back. The same thing happens in a few other filters too:
#74551 (comment)

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

@ashb

ashb commented Oct 13, 2026

Copy link
Copy Markdown
Member

Oof.

by bumping the last character to the next Unicode code point

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.

@ehddnr301

Copy link
Copy Markdown
Author

Oof.

by bumping the last character to the next Unicode code point

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 substr(dag_display_name, 1, len(prefix)) = prefix, so collation order doesn't matter there. Those searches just won't use the index.

You were right about it being fragile though, and it's not just Unicode. With an ICU Czech collation, where ch sorts after h, a c prefix search misses chata (PG 16.15, cs-CZ-x-icu). Not a common setup for Airflow, and I haven't seen it with en_US.utf8, but it shows the bump approach depends on the collation.

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.
@ehddnr301

Copy link
Copy Markdown
Author

@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 카페 and café matches are returned. The added condition skips the upper bound when its incremented character is non-ASCII. The lower bound and substring equality stay; ASCII searches are unchanged.

Search results and timing

These are 카페 results on a PostgreSQL 16 en_US.utf8 indexed column. Times are count + list totals (ms, warm cache).

Table rows Matches before Matches now Before (ms) Now (ms)
1,000 0 2 0.015 0.352
10,000 0 2 0.015 2.977
100,000 0 20 0.017 34.354
200,000 0 40 0.015 69.550
1,000,000 0 200 0.019 252.753

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 카페 search above took about 0.25 seconds even at 1m rows. I judged that this query time would not significantly hurt the search experience. Could you review whether this is suitable to merge with that scope?

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. 커피매출000000001, 카asdfasdfasdf페000000007).

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.

Table rows 카페 search (ms) 16-char no-match (ms) Maximum for the four terms below (ms)
1,000 0.352 0.063 2.808
10,000 2.977 0.407 26.485
100,000 34.354 8.069 271.374
200,000 69.550 17.001 541.970
1,000,000 252.753 179.740 2019.372

Warm cache, one warmup and three measured runs per query. Times sum the medians of count and ORDER BY id LIMIT 100, excluding HTTP overhead. All before/after results are below.

The four search terms shown

  • 카페 (2 chars): 카페
  • Mixed prefix (14 chars): 카asdfasdfasdf페
  • 49-char sentence (49 chars): 카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페
  • Mixed, no match (16 chars): 카asdfasdfasdf없는페

en_US.utf8 / indexed column: 20 comparisons

Table rows Search Chars Matches before Matches now Before (ms) Now (ms)
1,000 카페 2 0 (miss) 2 0.015 0.352
1,000 Mixed prefix 14 0 (miss) 1 0.015 0.058
1,000 49-char sentence 49 0 (miss) 2 0.045 2.808
1,000 Mixed, no match 16 0 0 0.015 0.063
10,000 카페 2 0 (miss) 2 0.015 2.977
10,000 Mixed prefix 14 0 (miss) 1 0.018 0.397
10,000 49-char sentence 49 0 (miss) 2 0.054 26.308
10,000 Mixed, no match 16 0 0 0.018 0.407
100,000 카페 2 0 (miss) 20 0.017 34.354
100,000 Mixed prefix 14 0 (miss) 10 0.019 7.970
100,000 49-char sentence 49 0 (miss) 20 0.063 270.176
100,000 Mixed, no match 16 0 0 0.017 8.069
200,000 카페 2 0 (miss) 40 0.015 69.550
200,000 Mixed prefix 14 0 (miss) 20 0.017 16.697
200,000 49-char sentence 49 0 (miss) 40 0.068 536.694
200,000 Mixed, no match 16 0 0 0.017 17.001
1,000,000 카페 2 0 (miss) 200 0.019 252.753
1,000,000 Mixed prefix 14 0 (miss) 100 0.020 177.925
1,000,000 49-char sentence 49 0 (miss) 200 0.071 2002.212
1,000,000 Mixed, no match 16 0 0 0.018 179.740

en_US.utf8 / display-name CASE: 20 comparisons

Table rows Search Chars Matches before Matches now Before (ms) Now (ms)
1,000 카페 2 0 (miss) 2 0.404 0.338
1,000 Mixed prefix 14 0 (miss) 1 0.242 0.240
1,000 49-char sentence 49 0 (miss) 2 4.925 2.689
1,000 Mixed, no match 16 0 0 0.227 0.235
10,000 카페 2 0 (miss) 2 3.710 3.124
10,000 Mixed prefix 14 0 (miss) 1 2.049 2.153
10,000 49-char sentence 49 0 (miss) 2 48.831 26.485
10,000 Mixed, no match 16 0 0 2.054 2.152
100,000 카페 2 0 (miss) 20 39.987 37.256
100,000 Mixed prefix 14 0 (miss) 10 23.309 26.732
100,000 49-char sentence 49 0 (miss) 20 492.300 271.374
100,000 Mixed, no match 16 0 0 23.218 26.669
200,000 카페 2 0 (miss) 40 79.546 73.783
200,000 Mixed prefix 14 0 (miss) 20 47.540 53.425
200,000 49-char sentence 49 0 (miss) 40 982.313 541.970
200,000 Mixed, no match 16 0 0 47.040 52.974
1,000,000 카페 2 0 (miss) 200 398.353 266.703
1,000,000 Mixed prefix 14 0 (miss) 100 235.440 268.431
1,000,000 49-char sentence 49 0 (miss) 200 4951.882 2019.372
1,000,000 Mixed, no match 16 0 0 235.867 264.860

C / indexed column: 20 comparisons

Table rows Search Chars Matches before Matches now Before (ms) Now (ms)
1,000 카페 2 2 2 0.016 0.151
1,000 Mixed prefix 14 1 1 0.015 0.225
1,000 49-char sentence 49 2 2 0.017 0.225
1,000 Mixed, no match 16 0 0 0.013 0.205
10,000 카페 2 2 2 0.019 1.236
10,000 Mixed prefix 14 1 1 0.019 1.919
10,000 49-char sentence 49 2 2 0.021 1.927
10,000 Mixed, no match 16 0 0 0.013 1.923
100,000 카페 2 20 20 0.030 16.987
100,000 Mixed prefix 14 10 10 0.026 23.745
100,000 49-char sentence 49 20 20 0.037 23.747
100,000 Mixed, no match 16 0 0 0.016 23.687
200,000 카페 2 40 40 0.048 34.964
200,000 Mixed prefix 14 20 20 0.028 48.684
200,000 49-char sentence 49 40 40 0.053 48.811
200,000 Mixed, no match 16 0 0 0.017 48.153
1,000,000 카페 2 200 200 0.122 122.964
1,000,000 Mixed prefix 14 100 100 0.076 237.350
1,000,000 49-char sentence 49 200 200 0.196 174.874
1,000,000 Mixed, no match 16 0 0 0.013 240.279

C / display-name CASE: 20 comparisons

Table rows Search Chars Matches before Matches now Before (ms) Now (ms)
1,000 카페 2 2 2 0.141 0.190
1,000 Mixed prefix 14 1 1 0.113 0.219
1,000 49-char sentence 49 2 2 0.117 0.222
1,000 Mixed, no match 16 0 0 0.110 0.220
10,000 카페 2 2 2 1.022 1.459
10,000 Mixed prefix 14 1 1 1.021 2.122
10,000 49-char sentence 49 2 2 1.041 2.121
10,000 Mixed, no match 16 0 0 0.994 2.124
100,000 카페 2 20 20 12.637 19.008
100,000 Mixed prefix 14 10 10 12.683 26.297
100,000 49-char sentence 49 20 20 12.721 26.202
100,000 Mixed, no match 16 0 0 12.197 25.877
200,000 카페 2 40 40 26.239 39.269
200,000 Mixed prefix 14 20 20 25.914 53.219
200,000 49-char sentence 49 40 40 26.452 52.663
200,000 Mixed, no match 16 0 0 25.760 53.319
1,000,000 카페 2 200 200 132.432 141.651
1,000,000 Mixed prefix 14 100 100 133.317 261.058
1,000,000 49-char sentence 49 200 200 135.488 193.879
1,000,000 Mixed, no match 16 0 0 129.474 264.647

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.

Table rows Non-ASCII Term DB Matches before Matches now Before (ms) Now (ms)
200,000 50% dag_0012 PostgreSQL 16 500 500 0.370 0.330
200,000 50% dag_0012 MySQL 8.0 500 500 0.340 0.350
200,000 50% dag_0012 SQLite 500 500 0.070 0.070
200,000 50% münchen PostgreSQL 16 16,666 16,666 4.690 4.690
200,000 50% 카페a PostgreSQL 16 0 0 0.190 0.170
200,000 50% 카페 PostgreSQL 16 0 (miss) 16,667 0.160 15.890
200,000 50% café PostgreSQL 16 0 (miss) 16,667 0.160 14.630
200,000 50% 카페 MySQL 8.0 16,667 16,667 3.360 4.220
200,000 50% café MySQL 8.0 0 (miss) 16,667 0.130 21.560
200,000 50% 카페 SQLite 16,667 16,667 1.000 1.510
200,000 50% café SQLite 16,667 16,667 1.010 9.350
200,000 2% dag_0012 PostgreSQL 16 980 980 0.500 0.470
200,000 2% 카페 PostgreSQL 16 0 (miss) 667 0.120 12.060
200,000 2% café PostgreSQL 16 0 (miss) 667 0.120 11.130

Drafted-by: Codex (GPT-6); reviewed by ehddnr301 before posting

@ashb

ashb commented Oct 15, 2026

Copy link
Copy Markdown
Member

250ms across 1 m rows is "slow bit acceptable" territory.

Could you show an explain analyse output for some of these larger cases please?

@ehddnr301

Copy link
Copy Markdown
Author

@ashb, here are the EXPLAIN ANALYZE outputs for the 1m-row cases!

Prefix search on 1m rows

With the same setup, the 1m-row 카페 search reran at 252.186 ms for count + page (previously 252.753 ms).

Count uses a full table scan. The page query uses the primary-key index for ORDER BY id, filtering until it finds 100 matches. Neither uses the name index to narrow the prefix search.

Term Earlier total (ms) Rerun total (ms)
카페 252.753 252.186
49-character term 2002.212 1994.487
1m rows: the ~250 ms 카페 case — SQL / EXPLAIN ANALYZE

Setup: PostgreSQL 16.15 / en_US.utf8, temporary tables populated with generated test data, warm cache, ORDER BY id LIMIT 100. Totals sum the count and page execution-time medians from three runs after one warmup, excluding planning time. Text plans are additional executions and can differ slightly from the tabulated medians.

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;
Aggregate  (cost=29722.50..29722.51 rows=1 width=8) (actual time=163.969..163.970 rows=1 loops=1)
  Buffers: local hit=1 read=12209
  ->  Seq Scan on long_prefix_probe  (cost=0.00..29710.00 rows=5000 width=0) (actual time=0.006..163.953 rows=200 loops=1)
        Filter: ((name_locale >= '카페'::text) AND (substr(name_locale, 1, 2) = '카페'::text))
        Rows Removed by Filter: 999800
        Buffers: local hit=1 read=12209
Planning:
  Buffers: local read=4
Planning Time: 0.073 ms
Execution Time: 163.984 ms

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;
Limit  (cost=0.42..914.28 rows=100 width=4) (actual time=0.011..89.205 rows=100 loops=1)
  Buffers: local hit=6 read=7324
  ->  Index Scan using long_prefix_probe_pkey on long_prefix_probe  (cost=0.42..45693.43 rows=5000 width=4) (actual time=0.010..89.198 rows=100 loops=1)
        Filter: ((name_locale >= '카페'::text) AND (substr(name_locale, 1, 2) = '카페'::text))
        Rows Removed by Filter: 489909
        Buffers: local hit=6 read=7324
Planning:
  Buffers: local read=4
Planning Time: 0.058 ms
Execution Time: 89.214 ms

The 49-character term

The 49-character search uses the same scan types and spends more time in the scan nodes.

1m rows: 49-character term — SQL / EXPLAIN ANALYZE

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, 49) =
            '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'
) AS anon_1;
Aggregate  (cost=29722.50..29722.51 rows=1 width=8) (actual time=1331.468..1331.469 rows=1 loops=1)
  Buffers: local hit=1 read=12209
  ->  Seq Scan on long_prefix_probe  (cost=0.00..29710.00 rows=5000 width=0) (actual time=0.016..1331.449 rows=200 loops=1)
        Filter: ((name_locale >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text) AND (substr(name_locale, 1, 49) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text))
        Rows Removed by Filter: 999800
        Buffers: local hit=1 read=12209
Planning:
  Buffers: local read=4
Planning Time: 0.085 ms
Execution Time: 1331.483 ms

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;
Limit  (cost=0.42..914.28 rows=100 width=4) (actual time=0.021..663.904 rows=100 loops=1)
  Buffers: local hit=6 read=7324
  ->  Index Scan using long_prefix_probe_pkey on long_prefix_probe  (cost=0.42..45693.43 rows=5000 width=4) (actual time=0.021..663.896 rows=100 loops=1)
        Filter: ((name_locale >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text) AND (substr(name_locale, 1, 49) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text))
        Rows Removed by Filter: 489909
        Buffers: local hit=6 read=7324
Planning:
  Buffers: local read=4
Planning Time: 0.088 ms
Execution Time: 663.917 ms

Drafted-by: Codex (GPT-6.1), Claude (5.5); reviewed by ehddnr301 before posting

@ehddnr301

Copy link
Copy Markdown
Author

UI API measurements

I called /ui/dags on 1m Dags with display-name ordering and 50 rows per page. The local API request for the 49-character term took 981 ms.

Term Count + page (ms) Local API request (ms)
cafe 113.587 151.428
카페 146.463 189.918
49-character term 934.327 980.883

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 Parallel Seq Scan with two workers.

Setup and execution plans

PostgreSQL 16.15 / en_US.utf8, Airflow schema and stock indexes. Each term matched 200 Dags and returned the first 50, ordered by display name and Dag ID. Request parameters: limit=50, offset=0, exclude_stale=true, dag_runs_limit=1.

One warmup, then three measured runs; the table shows medians. DB totals sum the count and page query medians. Local TestClient timings include the route’s other queries and serialization, without browser or network latency. These are controlled test results.

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: 카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페

cafe

Total count

EXPLAIN (ANALYZE, BUFFERS)
SELECT count(*) AS count_1 
FROM (SELECT dag.dag_id AS dag_id, dag.is_paused AS is_paused, dag.is_draining AS is_draining, dag.is_stale AS is_stale, dag.exceeds_max_non_backfill AS exceeds_max_non_backfill, dag.last_parsed_time AS last_parsed_time, dag.last_parse_duration AS last_parse_duration, dag.last_expired AS last_expired, dag.fileloc AS fileloc, dag.relative_fileloc AS relative_fileloc, dag.bundle_name AS bundle_name, dag.bundle_version AS bundle_version, dag.owners AS owners, dag.dag_display_name AS dag_display_name, dag.description AS description, dag.timetable_type AS timetable_type, dag.timetable_summary AS timetable_summary, dag.timetable_description AS timetable_description, dag.timetable_partitioned AS timetable_partitioned, dag.timetable_periodic AS timetable_periodic, dag.timetable_asset_gated AS timetable_asset_gated, dag.partition_mapper_info AS partition_mapper_info, dag.asset_expression AS asset_expression, dag.deadline AS deadline, dag.max_active_tasks AS max_active_tasks, dag.max_active_runs AS max_active_runs, dag.max_consecutive_failed_dag_runs AS max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits AS has_task_concurrency_limits, dag.has_import_errors AS has_import_errors, dag.fail_fast AS fail_fast, dag.allowed_run_types AS allowed_run_types, dag.next_dagrun AS next_dagrun, dag.next_dagrun_data_interval_start AS next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end AS next_dagrun_data_interval_end, dag.next_dagrun_partition_key AS next_dagrun_partition_key, dag.next_dagrun_partition_date AS next_dagrun_partition_date, dag.next_dagrun_create_after AS next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= 'cafe'::VARCHAR AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END < 'caff'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 4::INTEGER) = 'cafe'::VARCHAR) AS anon_1;
Finalize Aggregate  (cost=29749.57..29749.58 rows=1 width=8) (actual time=52.004..56.610 rows=1 loops=1)
  Buffers: shared hit=16150 read=4266 written=96
  ->  Gather  (cost=29749.36..29749.57 rows=2 width=8) (actual time=51.939..56.606 rows=3 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16150 read=4266 written=96
        ->  Partial Aggregate  (cost=28749.36..28749.37 rows=1 width=8) (actual time=43.788..43.788 rows=1 loops=3)
              Buffers: shared hit=16150 read=4266 written=96
              ->  Parallel Seq Scan on dag  (cost=0.00..28749.33 rows=10 width=0) (actual time=0.964..43.781 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= 'cafe'::text) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text < 'caff'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 4) = 'cafe'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16150 read=4266 written=96
Planning Time: 0.061 ms
Execution Time: 56.624 ms

Page

EXPLAIN (ANALYZE, BUFFERS)
SELECT dag.dag_id, dag.is_paused, dag.is_draining, dag.is_stale, dag.exceeds_max_non_backfill, dag.last_parsed_time, dag.last_parse_duration, dag.last_expired, dag.fileloc, dag.relative_fileloc, dag.bundle_name, dag.bundle_version, dag.owners, dag.dag_display_name, dag.description, dag.timetable_type, dag.timetable_summary, dag.timetable_description, dag.timetable_partitioned, dag.timetable_periodic, dag.timetable_asset_gated, dag.partition_mapper_info, dag.asset_expression, dag.deadline, dag.max_active_tasks, dag.max_active_runs, dag.max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits, dag.has_import_errors, dag.fail_fast, dag.allowed_run_types, dag.next_dagrun, dag.next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end, dag.next_dagrun_partition_key, dag.next_dagrun_partition_date, dag.next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= 'cafe'::VARCHAR AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END < 'caff'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 4::INTEGER) = 'cafe'::VARCHAR ORDER BY CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END ASC, dag.dag_id ASC 
 LIMIT 50::INTEGER OFFSET 0::INTEGER;
Limit  (cost=29749.52..29751.86 rows=20 width=2318) (actual time=52.228..56.700 rows=50 loops=1)
  Buffers: shared hit=16242 read=4250 written=96
  ->  Gather Merge  (cost=29749.52..29751.86 rows=20 width=2318) (actual time=52.227..56.691 rows=50 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16242 read=4250 written=96
        ->  Sort  (cost=28749.50..28749.52 rows=10 width=2318) (actual time=43.726..43.728 rows=45 loops=3)
              Sort Key: (CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END), dag_id
              Sort Method: quicksort  Memory: 45kB
              Buffers: shared hit=16242 read=4250 written=96
              Worker 0:  Sort Method: quicksort  Memory: 38kB
              Worker 1:  Sort Method: quicksort  Memory: 42kB
              ->  Parallel Seq Scan on dag  (cost=0.00..28749.33 rows=10 width=2318) (actual time=0.879..43.664 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= 'cafe'::text) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text < 'caff'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 4) = 'cafe'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16166 read=4250 written=96
Planning Time: 0.075 ms
Execution Time: 56.723 ms

카페

Total count

EXPLAIN (ANALYZE, BUFFERS)
SELECT count(*) AS count_1 
FROM (SELECT dag.dag_id AS dag_id, dag.is_paused AS is_paused, dag.is_draining AS is_draining, dag.is_stale AS is_stale, dag.exceeds_max_non_backfill AS exceeds_max_non_backfill, dag.last_parsed_time AS last_parsed_time, dag.last_parse_duration AS last_parse_duration, dag.last_expired AS last_expired, dag.fileloc AS fileloc, dag.relative_fileloc AS relative_fileloc, dag.bundle_name AS bundle_name, dag.bundle_version AS bundle_version, dag.owners AS owners, dag.dag_display_name AS dag_display_name, dag.description AS description, dag.timetable_type AS timetable_type, dag.timetable_summary AS timetable_summary, dag.timetable_description AS timetable_description, dag.timetable_partitioned AS timetable_partitioned, dag.timetable_periodic AS timetable_periodic, dag.timetable_asset_gated AS timetable_asset_gated, dag.partition_mapper_info AS partition_mapper_info, dag.asset_expression AS asset_expression, dag.deadline AS deadline, dag.max_active_tasks AS max_active_tasks, dag.max_active_runs AS max_active_runs, dag.max_consecutive_failed_dag_runs AS max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits AS has_task_concurrency_limits, dag.has_import_errors AS has_import_errors, dag.fail_fast AS fail_fast, dag.allowed_run_types AS allowed_run_types, dag.next_dagrun AS next_dagrun, dag.next_dagrun_data_interval_start AS next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end AS next_dagrun_data_interval_end, dag.next_dagrun_partition_key AS next_dagrun_partition_key, dag.next_dagrun_partition_date AS next_dagrun_partition_date, dag.next_dagrun_create_after AS next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= '카페'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 2::INTEGER) = '카페'::VARCHAR) AS anon_1;
Finalize Aggregate  (cost=28709.62..28709.63 rows=1 width=8) (actual time=67.633..72.252 rows=1 loops=1)
  Buffers: shared hit=16150 read=4266 written=93
  ->  Gather  (cost=28709.40..28709.61 rows=2 width=8) (actual time=67.575..72.248 rows=3 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16150 read=4266 written=93
        ->  Partial Aggregate  (cost=27709.40..27709.41 rows=1 width=8) (actual time=59.295..59.296 rows=1 loops=3)
              Buffers: shared hit=16150 read=4266 written=93
              ->  Parallel Seq Scan on dag  (cost=0.00..27707.67 rows=695 width=0) (actual time=1.137..59.288 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= '카페'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 2) = '카페'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16150 read=4266 written=93
Planning Time: 0.067 ms
Execution Time: 72.267 ms

Page

EXPLAIN (ANALYZE, BUFFERS)
SELECT dag.dag_id, dag.is_paused, dag.is_draining, dag.is_stale, dag.exceeds_max_non_backfill, dag.last_parsed_time, dag.last_parse_duration, dag.last_expired, dag.fileloc, dag.relative_fileloc, dag.bundle_name, dag.bundle_version, dag.owners, dag.dag_display_name, dag.description, dag.timetable_type, dag.timetable_summary, dag.timetable_description, dag.timetable_partitioned, dag.timetable_periodic, dag.timetable_asset_gated, dag.partition_mapper_info, dag.asset_expression, dag.deadline, dag.max_active_tasks, dag.max_active_runs, dag.max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits, dag.has_import_errors, dag.fail_fast, dag.allowed_run_types, dag.next_dagrun, dag.next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end, dag.next_dagrun_partition_key, dag.next_dagrun_partition_date, dag.next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= '카페'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 2::INTEGER) = '카페'::VARCHAR ORDER BY CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END ASC, dag.dag_id ASC 
 LIMIT 50::INTEGER OFFSET 0::INTEGER;
Limit  (cost=28730.78..28736.61 rows=50 width=2318) (actual time=68.425..72.855 rows=50 loops=1)
  Buffers: shared hit=16242 read=4250 written=96
  ->  Gather Merge  (cost=28730.78..28892.96 rows=1390 width=2318) (actual time=68.424..72.851 rows=50 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16242 read=4250 written=96
        ->  Sort  (cost=27730.75..27732.49 rows=695 width=2318) (actual time=59.930..59.932 rows=44 loops=3)
              Sort Key: (CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END), dag_id
              Sort Method: quicksort  Memory: 90kB
              Buffers: shared hit=16242 read=4250 written=96
              Worker 0:  Sort Method: quicksort  Memory: 65kB
              Worker 1:  Sort Method: quicksort  Memory: 70kB
              ->  Parallel Seq Scan on dag  (cost=0.00..27707.67 rows=695 width=2318) (actual time=0.430..59.536 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= '카페'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 2) = '카페'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16166 read=4250 written=96
Planning Time: 0.073 ms
Execution Time: 72.877 ms

49-character term

Total count

EXPLAIN (ANALYZE, BUFFERS)
SELECT count(*) AS count_1 
FROM (SELECT dag.dag_id AS dag_id, dag.is_paused AS is_paused, dag.is_draining AS is_draining, dag.is_stale AS is_stale, dag.exceeds_max_non_backfill AS exceeds_max_non_backfill, dag.last_parsed_time AS last_parsed_time, dag.last_parse_duration AS last_parse_duration, dag.last_expired AS last_expired, dag.fileloc AS fileloc, dag.relative_fileloc AS relative_fileloc, dag.bundle_name AS bundle_name, dag.bundle_version AS bundle_version, dag.owners AS owners, dag.dag_display_name AS dag_display_name, dag.description AS description, dag.timetable_type AS timetable_type, dag.timetable_summary AS timetable_summary, dag.timetable_description AS timetable_description, dag.timetable_partitioned AS timetable_partitioned, dag.timetable_periodic AS timetable_periodic, dag.timetable_asset_gated AS timetable_asset_gated, dag.partition_mapper_info AS partition_mapper_info, dag.asset_expression AS asset_expression, dag.deadline AS deadline, dag.max_active_tasks AS max_active_tasks, dag.max_active_runs AS max_active_runs, dag.max_consecutive_failed_dag_runs AS max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits AS has_task_concurrency_limits, dag.has_import_errors AS has_import_errors, dag.fail_fast AS fail_fast, dag.allowed_run_types AS allowed_run_types, dag.next_dagrun AS next_dagrun, dag.next_dagrun_data_interval_start AS next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end AS next_dagrun_data_interval_end, dag.next_dagrun_partition_key AS next_dagrun_partition_key, dag.next_dagrun_partition_date AS next_dagrun_partition_date, dag.next_dagrun_create_after AS next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 49::INTEGER) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::VARCHAR) AS anon_1;
Finalize Aggregate  (cost=28709.62..28709.63 rows=1 width=8) (actual time=461.479..466.377 rows=1 loops=1)
  Buffers: shared hit=16017 read=4399 written=2
  ->  Gather  (cost=28709.40..28709.61 rows=2 width=8) (actual time=461.424..466.372 rows=3 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16017 read=4399 written=2
        ->  Partial Aggregate  (cost=27709.40..27709.41 rows=1 width=8) (actual time=453.668..453.669 rows=1 loops=3)
              Buffers: shared hit=16017 read=4399 written=2
              ->  Parallel Seq Scan on dag  (cost=0.00..27707.67 rows=695 width=0) (actual time=8.353..453.657 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 49) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16017 read=4399 written=2
Planning Time: 0.071 ms
Execution Time: 466.394 ms

Page

EXPLAIN (ANALYZE, BUFFERS)
SELECT dag.dag_id, dag.is_paused, dag.is_draining, dag.is_stale, dag.exceeds_max_non_backfill, dag.last_parsed_time, dag.last_parse_duration, dag.last_expired, dag.fileloc, dag.relative_fileloc, dag.bundle_name, dag.bundle_version, dag.owners, dag.dag_display_name, dag.description, dag.timetable_type, dag.timetable_summary, dag.timetable_description, dag.timetable_partitioned, dag.timetable_periodic, dag.timetable_asset_gated, dag.partition_mapper_info, dag.asset_expression, dag.deadline, dag.max_active_tasks, dag.max_active_runs, dag.max_consecutive_failed_dag_runs, dag.has_task_concurrency_limits, dag.has_import_errors, dag.fail_fast, dag.allowed_run_types, dag.next_dagrun, dag.next_dagrun_data_interval_start, dag.next_dagrun_data_interval_end, dag.next_dagrun_partition_key, dag.next_dagrun_partition_date, dag.next_dagrun_create_after 
FROM dag 
WHERE dag.is_stale != true AND CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::VARCHAR AND substr(CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END, 1::INTEGER, 49::INTEGER) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::VARCHAR ORDER BY CASE WHEN (dag.dag_display_name IS NOT NULL) THEN dag.dag_display_name ELSE dag.dag_id END ASC, dag.dag_id ASC 
 LIMIT 50::INTEGER OFFSET 0::INTEGER;
Limit  (cost=28730.78..28736.61 rows=50 width=2318) (actual time=460.816..465.481 rows=50 loops=1)
  Buffers: shared hit=16261 read=4231 written=1
  ->  Gather Merge  (cost=28730.78..28892.96 rows=1390 width=2318) (actual time=460.815..465.477 rows=50 loops=1)
        Workers Planned: 2
        Workers Launched: 2
        Buffers: shared hit=16261 read=4231 written=1
        ->  Sort  (cost=27730.75..27732.49 rows=695 width=2318) (actual time=452.327..452.328 rows=38 loops=3)
              Sort Key: (CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END), dag_id
              Sort Method: quicksort  Memory: 82kB
              Buffers: shared hit=16261 read=4231 written=1
              Worker 0:  Sort Method: quicksort  Memory: 67kB
              Worker 1:  Sort Method: quicksort  Memory: 76kB
              ->  Parallel Seq Scan on dag  (cost=0.00..27707.67 rows=695 width=2318) (actual time=2.209..451.915 rows=67 loops=3)
                    Filter: ((NOT is_stale) AND ((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text >= '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text) AND (substr((CASE WHEN (dag_display_name IS NOT NULL) THEN dag_display_name ELSE dag_id END)::text, 1, 49) = '카페에서 매일 수집한 매출 데이터를 지역과 상품별로 정리하고 검증한 결과를 보고하는 카페'::text))
                    Rows Removed by Filter: 333267
                    Buffers: shared hit=16185 read=4231 written=1
Planning Time: 0.085 ms
Execution Time: 465.506 ms

Drafted-by: Codex (GPT-6.1), Claude (5.5); reviewed by ehddnr301 before posting

@ehddnr301

Copy link
Copy Markdown
Author

Hi @ashb, I've added the query plans and UI API timings above. Could you take another look when you have a chance? Thanks!

This branch has not been deployed

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

Labels

area:API Airflow's REST/HTTP API area:UI Related to UI/UX. For Frontend Developers.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants