-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
perf(core): Add index for jobs last_checked, reserved_at, time_sensitive #47324
Conversation
Signed-off-by: provokateurin <[email protected]>
80b8115
to
6539e32
Compare
# Add updated index | ||
if (!$table->hasIndex('job_last_reserved_sensitive')) { | ||
$table->addIndex(['last_checked', 'reserved_at', 'time_sensitive'], 'job_last_reserved_sensitive'); | ||
} |
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.
# Add updated index | |
if (!$table->hasIndex('job_last_reserved_sensitive')) { | |
$table->addIndex(['last_checked', 'reserved_at', 'time_sensitive'], 'job_last_reserved_sensitive'); | |
} |
This should be done only on new installations and otherwise the change in core/Application.php
takes care?
The best to achieve this is modifying the original migration that added the old indexes (you should also comment them out with a reference that Version31000Date20240819122840.php
deletes them).
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.
So just keep the old indices?
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.
No, deleting is fine. Just not creating new ones
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.
\OC\Core\Migrations\Version13000Date20170718121200::changeSchema
still creates the old index. Comment it out and add the new index with a comment as well saying that the indices were changed later on
|
||
# Add updated index | ||
if (!$table->hasIndex('job_last_reserved_sensitive')) { | ||
$table->addIndex(['last_checked', 'reserved_at', 'time_sensitive'], 'job_last_reserved_sensitive'); |
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.
Adding an index can be slow if there is a lot of data. Would it be possible to use https://docs.nextcloud.com/server/latest/developer_manual/basics/storage/migrations.html#replacing-indices instead?
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.
yeah, that's the first change she did in core/Application
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.
Ah I didn't know about the possibility to replace indices.
So should I replace or only add the index in Application.php? |
Correct way is:
|
use OCP\Migration\IOutput; | ||
use OCP\Migration\SimpleMigrationStep; | ||
|
||
class Version31000Date20240819122840 extends SimpleMigrationStep { |
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.
See https://github.com/nextcloud/server/pull/46974/files#diff-a13c08ddffcec08aa3dfe030b79869cd4b164cf35f9a4fff0e22dbe9848b552eR20 for examples, DB migrations for 30+ should be annotated for the new 30+ feature to work 👍
I'm skeptical about this because it will leave instances in an unindexed state after the upgrade, until the admins apply optional indices. So my counter proposal is
|
Summary
Replaces the two existing indices with a single shared index saving some time on queries previously using both separate indices.
Checklist