Skip to content

Parallelize infer_schema #19970

Open

Description

@Dandandan

Is your feature request related to a problem or challenge?

Currently infer_schema runs in a single thread.

Also it uses buffered instead of buffer_unordered (the latter will be better if some reads are taking much longer than others).

You can see below it takes ~130ms just to load the schema/metadata for the (100) clickbench_partitioned files.

Image

Describe the solution you'd like

We should be able to use all threads.

Describe alternatives you've considered

No response

Additional context

No response

Activity

  1. alamb commented on Jan 25, 2026

    @alamb
    Contributor

    FWIW the actual clickbench runs (on benchmark.clickhouse.com) don't count the time to CREATE EXTERNAL TABLE

    So if the schema inference isn't part of of the actual query, this optimization may not help the benchmark results

    It is not a bad thing to do, I am just commenting regarding the benchmark

  2. Dandandan commented on Jan 25, 2026

    @Dandandan
    ContributorAuthor

    Ah yes, you are right.

    Looking at the benchmark, the difference between cold and warm run is quite high (notacibly higher than some others engines) - I believe list_files_for_scan #19971 is part of the cold run?

    https://benchmark.clickhouse.com/#system=+ti%20rud&type=-&machine=+g4e&cluster_size=-&opensource=-&hardware=-&tuned=+n&metric=cold&queries=-

  3. zhuqi-lucas commented on Mar 8, 2026

    @zhuqi-lucas
    Contributor

    Hi @Dandandan @alamb, is this still being actively pursued?
    We have a use case that would benefit from this — inferring schemas from complex nested JSON files can be quite slow today, especially when there are many files or deeply nested structures. Faster schema inference would meaningfully improve our workflow.
    Happy to contribute or help test if this is still moving forward!

  4. alamb commented on Mar 10, 2026

    @alamb
    Contributor
  5. Dandandan commented on Mar 16, 2026

    @Dandandan
    ContributorAuthor

    Hi @Dandandan @alamb, is this still being actively pursued? We have a use case that would benefit from this — inferring schemas from complex nested JSON files can be quite slow today, especially when there are many files or deeply nested structures. Faster schema inference would meaningfully improve our workflow. Happy to contribute or help test if this is still moving forward!

    Go ahead, I think it's a nice issue. Did you also see (perhaps you can help reviewing?):

    apache/arrow-rs#9494

    One other thing I saw that also might be worth looking at is that we always create > 32 threads when doing metadata reading based on the configuration. Not a huge problem per-se but it adds to the memory usage (as the threads won't be removed) and probably reduces locality a bit while running queries.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions