Skip to content

[EPIC] A collection of tickets for improving sorting larger than memory datasets / spilling sorts #15271

Closed

Description

@alamb

There is a lot of work to support plans like SELECT * .. ORDER BY x,y,z when that data doesn't all fit in RAM.

I believe the core usecase is "compaction" where multiple small files are resorted/merged/written as larger fiiles

FYI @2010YOUY01 and @Kontinuation I was trying to find some other organizing ticket for improvements in this area and I could not, so I filed this one

Related:

Activity

  1. changed the title [-][EPIC] A collection of tickets for improving sorting larger-than-ram datasets[/-] [+][EPIC] A collection of tickets for improving sorting larger-than-ram datasets / spilling sorts[/+] on Mar 17, 2025
  2. alamb commented on Mar 17, 2025

    @alamb
    ContributorAuthor

    I also think that by collecting the related items we may be able to find some more review capacity (as I think this is an important capability for Spark / Comet. FYI @comphead / @andygrove / @kazuyukitanimura )

  3. changed the title [-][EPIC] A collection of tickets for improving sorting larger-than-ram datasets / spilling sorts[/-] [+][EPIC] A collection of tickets for improving sorting larger than memory datasets / spilling sorts[/+] on Mar 17, 2025
  4. alamb commented on Mar 19, 2025

    @alamb
    ContributorAuthor

    I filed some more tickets about ways to improve performance with external spill files

  5. andygrove commented on Mar 19, 2025

    @andygrove
    Member

    I added #15323

  6. xudong963 commented on Mar 20, 2025

    @xudong963
    Member

    @alamb Thank you for summarizing, I'm also interested in this topic and may have more time to join the game in May, but I will keep an eye on the progress.

  7. rluvaton commented on Apr 2, 2025

    @rluvaton
    Member

    I saw while debugging some performance issue in AggregateExec I see that we keep all spilled files open (RefCountedTempFile as it keep tempfile which hold File).

    and also when merging we read at least 1 batch from every spill file:

    for spill in self.spill_state.spills.drain(..) {
    let stream = self.spill_state.spill_manager.read_spill_as_stream(spill)?;
    streams.push(stream);
    }

    so If I have a lot of spill files or if every batch is really huge (contains very large lists - like result for array_agg on large dataset) we have all of this in memory.

  8. alamb commented on Apr 3, 2025

    @alamb
    ContributorAuthor

    so If I have a lot of spill files or if every batch is really huge (contains very large lists - like result for array_agg on large dataset) we have all of this in memory.

    I think this is the same underlying cause as

  9. added
    EPICA larger project, actively underway, with sub tasks
    PROPOSAL EPICA proposal being discussed that is not yet fully underway
    and removed
    EPICA larger project, actively underway, with sub tasks
    on Aug 12, 2025
  10. alamb commented on Sep 16, 2025

    @alamb
    ContributorAuthor

    I think most of this epic is done and DataFusion now has a very solid spilling sort implementation 🎉

    To make the current state clear, I moved the issues that are not currently completed to a new epic and will close this one

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

    PROPOSAL EPICA proposal being discussed that is not yet fully underwayenhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions