-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Joining by a character column is slow, compared to joining by a factor column. #1386
Comments
dplyr should be taking advantage of R's global string cache for doing string matching when using in-memory objects. You only need to check if the relevant character pointers are the same. See https://github.com/wch/r-source/blob/4a2026e8e/src/main/relop.c#L564-L569, https://github.com/wch/r-source/blob/9d4e23e/src/main/memory.c#L3878-L3894 for the C implementation. |
It's a bit more complicated than that actually. Sometimes two different pointers are the same strings but with different encodings, and we want the But your point is great, I am looking into it right now. We base the hashing on the strings on some ordering (which respects encoding etc ...) but actually we only need to be able to differentiate them, not necessarily rank them. TBC |
Now getting :
which is much better than what we had before. Still above the suggested implementation using |
Wow, pretty quick!!! Thanks a lot 👍 |
@romainfrancois Is this a temporary update? I am running this test with the most recent version of dplyr, of which the version is 0.4.3, but the speed is slow. |
*_join()
functions are slow when the key is character. Do you have any plan to improve this?I think
*_join()
can be faster by factorizing the key beforehand in most cases. Futhermore, I believe the key should be treated as factor, since no one will try to join by some column where every row has a different value.The text was updated successfully, but these errors were encountered: