-
Notifications
You must be signed in to change notification settings - Fork 99
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 player key index in database to speedup player lookups #194
Conversation
player
key in data
table to speed up lookup by player.
This only adds the feature to new databases - we may need to consider a database structure update |
I believe the functionality of database structure upgrades can be further explored down the line. Adding this PR will effectively only bring a performance boost without any unintended side-effects for those that have already created the database. |
@lflare Great suggestion, thanks! I thought this was already implemented, I'm surprised it's not. Any chance you could demonstrate the improvements with a comparative set of |
Also, @Narimm / @lflare Add schema update here: https://github.com/AddstarMC/Prism-Bukkit/blob/master/src/main/java/me/botsko/prism/database/sql/SqlPrismDataSourceUpdater.java#L78 Bump version to 8 and call the update here: https://github.com/AddstarMC/Prism-Bukkit/blob/master/src/main/java/me/botsko/prism/Updater.java#L29 |
I am aware of the schema updater... it will need to be added before this is accepted |
I am not currently able to provide such timings comparisons, but the comparisons can be simply replicated with Either way, having an index on |
Not entirely sure if this conforms to standards and guidelines, but as I was doing some lookups the other day, I realised that all lookups involving players with global radius and insane times resulted in searches taking forever. This might help to alleviate that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I approve of the addition of this index; it will definitely help query performance. Good to see you will also auto-create it. My only suggestion would be to name the index ix_player_id
instead of just player
, but the name doesn't matter much, and the other index is already just location
To support the addition of database changes in SNAPSHOT releases . I would prefer that we dont version the db with every commit . I am not quite sure yet how to handle snapshot db updates - because the problem is anyone who installs a snapshot build wont get any updates in the final release. My tendency is to enforce running the latest update in any snapshot build - so we need any table alter statements to handles being run multiple times on a potentitall already updated DB--- OR check the db first and skip. |
This should work the same way you'd do it in any production deployment with schema changes. You don't version the DB with each commit, you version the change to the actual schema itself. The code commit is irrelevant, what's important is the merge to master. If you merge a schema change to master, you should always consider it final. Any further adjustment to the schema (even if you change your mind on how the previous schema change was done) should create a new version bump. So an individual PR (not commit) should contain a single schema version bump and once it's merged, that version and schema change is committed and can never be changed.
I don't really understand what you mean here, but IMO, we should just always be enforcing all merged schema changes in all environments. We should not require anyone who uses a snapshot to do anything special, there's no need for it. When the schema update is merged and they run the snapshot with it, it will update their schema and the schema version in the DB so it will never attempt the update again. |
That's my intention, to follow the convention of whatever has been done prior.
I reckon it will be quite simple to handle these kind of things, by having a value in the database that specifies the current database schema version, and from that, retroactively apply all the updates that need to be applied to match the database schema of the current. With that in mind, I believe it is best practice to version the schema as long as it makes it into a public build, like a snapshot. If changes are made to the schema, that should be added to the history, irregardless of however minor it is. It might not be a bad idea to take a look at how Laravel handles database schema versioning too. With all of that said and done, I do not believe that there is anything lacking in this PR? |
Here is an overview of what got changed by this pull request: Issues
======
- Added 1
See the complete overview on Codacy |
@@ -18,5 +18,6 @@ | |||
|
|||
void v6_to_v7(); | |||
|
|||
void v7_to_v8(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm if you want this resolved.
Not entirely sure if this conforms to standards and guidelines, but as I was doing some lookups the other day, I realised that all lookups involving players with global radius and insane times resulted in searches taking forever. This might help to alleviate that.