-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve action table indices #19472
Improve action table indices #19472
Conversation
Improve the indices on the action table by creating a covering index that covers the common queries and removes unhelpful indices. Fix go-gitea#16665 Signed-off-by: Andrew Thornton <art27@cantab.net>
Ideally we might want to wait till some functionality that would allow us to assert the ordering of the index entries eg. https://gitea.com/xorm/xorm/pulls/2137 is merged and xorm is updated |
Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Is there any scene to use |
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.
@lunny If I see that correctly, notifications?
So the first column of a composite index will become a standalone index column? |
If I had to guess how the database query optimizers are built, I'd say so. |
Co-authored-by: delvh <dev.lh@web.de>
Yes an index on (A, B, C, D) can provide indexes for (A), (A,B), (A,B,C) and (A,B,C,D).
If instead of having, INDEX(u_ua_and_r) INDEX(ua_and_r) INDEX(r) we could reorder things so we could just have one or two indices. See #16665 (comment):
One we have the OrderBy fix in we can change these indices to be:
But we'd need to check again on MySQL to ensure the position of created_unix is correct. It'd be helpful to check on postgres too. |
Wow, so let's wait #19849 |
Since #19874 merged, please resolve the conflicts. |
Signed-off-by: Andrew Thornton <art27@cantab.net>
I think we should try to get this in to 1.17 |
LGTM since it was scheduled in 1.17 before frozen |
"xorm.io/xorm/schemas" | ||
) | ||
|
||
type improveActionTableIndicesAction struct { |
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 don't know whether a private struct could work with xorm.
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'm not sure if you're meaning this as a comment, e.g. I didn't know that a private struct would work with xorm, or if you're trying to express doubt that this will work, e.g. I don't think a private struct will work with xorm.
It will work.
If you are given a pointer to a nonExportedStruct:
package someplace
type notExportedStruct {
Exported string
}
func NewNotExported() *notExportedStruct {
return ¬ExportedStruct{}
}
you can always create another copy of it using:
package main
import "someplace"
func main() {
notExported := somplace.NewNotExported()
val := reflect.ValueOf(notExported).Elem()
typ := val.Type()
newNotExportedVal := reflect.New(typ)
newNotExportedVal.Elem().FieldByName("Exported").SetString("I have been set by reflection")
fmt.Println(newNotExportedVal.Interface())
}
Which is what xorm does internally anyway.
Xorm doesn't need to know or be able to cast to the non-exported type - it just uses reflection to look across the exported fields which will always work or casts to interfaces it knows e.g. TableName. newNotExportedVal
can be cast to an interface{}
using the .Interface()
function as normal.
* giteaofficial/release/v1.17: (35 commits) Simplify and fix migration 216 (go-gitea#20036) Alter hook_task TEXT fields to LONGTEXT (go-gitea#20038) (go-gitea#20041) Backtick table name in generic orphan check (go-gitea#20019) (go-gitea#20037) Respond with a 401 on git push when password isn't changed yet (go-gitea#20027) Fix delete pull head ref for DeleteIssue (go-gitea#20032) (go-gitea#20034) use quoted regexp instead of git fixed-value (go-gitea#20030) Dump should only copy regular files and symlink regular files (go-gitea#20015) (go-gitea#20021) Return 404 when tag is broken (go-gitea#20024) [skip ci] Updated translations via Crowdin [skip ci] Updated translations via Crowdin Add fgprof pprof profiler (go-gitea#20005) [skip ci] Updated translations via Crowdin Improve action table indices (go-gitea#19472) Add dbconsistency checks for Stopwatches (go-gitea#20010) fix push mirrors URL are no longer displayed on the UI (go-gitea#20011) Empty log queue on flush and close (go-gitea#19994) [skip ci] Updated translations via Crowdin Stop spurious APIFormat stopwatches logs (go-gitea#20008) Fix CountOrphanedLabels in orphan check (go-gitea#20009) Write Commit-Graphs in RepositoryDumper (go-gitea#20004) ...
Improve the indices on the action table by creating a covering index that covers the
common queries and removes unhelpful indices.
Fix #16665
Signed-off-by: Andrew Thornton art27@cantab.net