rolling join is unexpectedly slow
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- r
- Domain
- data, performance
Research direction
No repository files or tests are named. Start by running the issue's reproducible data.table benchmark and comparing the indexed non-rolling join plus subset with the rolling join; determine what accounts for the timing difference and document or address the behavior so both approaches have an explained, validated result.
Written by the indexing model from the issue text.
Description
It seems that joining two tables based on non-roll columns and then subsetting the result based on the roll condition works faster than doing it all in one step. For example
set.seed(0)
dt <- data.table(
A = sample(x = 10^2, size = 10^8, replace = TRUE),
B = sample(x = 10^4, size = 10^8, replace = TRUE),
C = sample(seq.Date(as.Date("2000-01-01"), as.Date("2010-12-31"), by = "day"), size = 10^8, replace = TRUE)
)
jt <- data.table(A = 94L, B = 4778L, C = as.Date("2005-01-01"))
# Join on (A, B), then subset rows >= 2005-01-01
setindex(dt, "A", "B")
system.time(result1 <- dt[jt[, list(A, B)], on=c("A", "B"), nomatch = 0][C >= as.Date("2005-01-01")])
# user system elapsed
# 0.002 0.000 0.002
# Rolling join on (A, B, C)
setindex(dt, "A", "B", "C")
system.time(result2 <- jt[dt, on=c("A", "B", "C"), roll = TRUE, nomatch = 0])
# user system elapsed
# 10.943 0.809 11.793
all.equal(result1, result2) # TRUE
Why is the second join so much slower than the first in this example? Thanks!
sessionInfo()
R version 3.4.2 (2017-09-28)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: macOS Sierra 10.12.6
- Dominant language
- R
- Stars
- 3.9k
- Forks
- 1.1k
- Avg merge
- 14h 4m
- Merged PRs (30d)
- 4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Rdatatable/data.table
-
as.data.table() recurses without end on a survival::Surv object (or any data.frame carrying one) Open
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Rdatatable/data.table#7887 ·
-
consistency tests
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#7853 · 3 comments ·
-
internals
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#6938 · 1 comment ·
-
encoding fread
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Rdatatable/data.table#5179 · 8 comments ·
-
documentation programming
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Rdatatable/data.table#3199 · 3 comments ·
All issues in Rdatatable/data.table
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
r-lib/pkgdepends#485 · 3 comments ·
-
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
beginners blocker
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enviPathR OpenBuild Error Build OK Build Warning policies-accepted pre-review precheck-passed
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Bioconductor/BiocContributions#207 · 6 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
datacarpentry/semester-biology#1255 ·