Skip to content

[R] Optimize dplyr queries that use head/tail after arrange #28505

Closed

Description

@asfimport

Use the Arrow C++ function partition_nth_indices to optimize dplyr queries like this:

iris %>%
  Table$create() %>% 
  arrange(desc(Sepal.Length)) %>%
  head(10) %>%
  collect()

This query sorts the full table even though it doesn't need to. It could use partition_nth_indices to find the rows containing the top 10 values of Sepal.Length and only collect and sort those 10 rows.

Test to see if this improves performance in practice on larger data.

Reporter: Ian Cook / @ianmcook
Assignee: Neal Richardson / @nealrichardson

Related issues:

PRs and other links:

Note: This issue was originally created as ARROW-12763. Please see the migration documentation for further details.

Activity

  1. asfimport commented on Sep 28, 2021

    @asfimport
    Author

    Neal Richardson / @nealrichardson:
    See discussion on ARROW-13767. I think this means we should use the top_k node when that is added (ARROW-13973)

  2. asfimport commented on Oct 15, 2021

    @asfimport
    Author

    Jonathan Keane / @jonkeane:
    Issue resolved by pull request 11405
    #11405

  3. added this to the 6.0.0 milestone on Jan 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions