Skip to content
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

Add index for interactive search #493

Merged
merged 1 commit into from
Sep 10, 2022

Conversation

CosmicHorrorDev
Copy link
Contributor

Related #475 (cc @Byron)

This PR adds an index intended to improve the query for interactive search

I was able to artificially create bad startup times for atuin search --interactive by adding several thousand entries to my history with the same command. This stresses the max(timestamp) for a given command because there is no index to relate timestamps to their respective commands. With this I was able to reproduce an over 2 second startup time which became well under 1 second after this change

Opening as a draft because I want to see if this impact is noticeable for more organic histories. You can test by manually creating this index on your history.db

NOTE: for local testing your system installed atuin will get angry if extra migrations are applied that it doesn't recognize. You can still manually add the index using sqlite3 and it won't notice, but running atuin built from this PR while still having an older version installed still can give

Error: migration 20220806155627 was previously applied but is missing in the resolved migrations

Caused by:
    migration 20220806155627 was previously applied but is missing in the resolved migrations

Location:
    src/command/client.rs:68:22

@ellie
Copy link
Member

ellie commented Aug 6, 2022

I'd like to properly run the numbers for this, but anecdotally it seems faster :) thanks for looking into this!

Is Atuin any faster with this index for you @chrysn?

@conradludgate
Copy link
Collaborator

Adding this index increased my database from 10M to 12M. Not hugely worrying.

If we have this, do we need our existing indexes? I deleted them locally to no observable downside but maybe my number of entries is too low to see that impact

@conradludgate
Copy link
Collaborator

However, I do definitely notice a difference in search times with the new index. LGTM

@ellie
Copy link
Member

ellie commented Sep 10, 2022

I think let's keep the existing for now and review all indices later

@ellie ellie marked this pull request as ready for review September 10, 2022 10:21
@ellie ellie merged commit 8478a59 into atuinsh:main Sep 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants