-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Create missing database indexes #596
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
Create missing database indexes #596
Conversation
LGTM |
UpdatedUnix int64 | ||
HasRecentActivity bool `xorm:"-"` | ||
HasUsed bool `xorm:"-"` | ||
UpdatedUnix int64 `xorm:"INDEX"` |
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.
Ditto
@@ -21,11 +21,11 @@ type AccessToken struct { | |||
Sha1 string `xorm:"UNIQUE VARCHAR(40)"` | |||
|
|||
Created time.Time `xorm:"-"` | |||
CreatedUnix int64 | |||
CreatedUnix int64 `xorm:"INDEX"` |
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 think we ever issue SQL queries that use the created_unix
column of this table. Will adding an index here help us?
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.
It may not be useful in WHERE
, but I think it is/will on ORDER BY
.
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.
If my understanding of database indices is correct, a non-clustered index will not help ORDER BY
clauses.
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.
:) It seems your discuss is not end after I merged.
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.
a non-clustered index will not help ORDER BY clauses
I thought it would.
@ethantkoenig Since I'm not a databases guru, if you still think we should not have these indexes, feel free to open another PR. I'd merge it. 😃
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.
@ethantkoenig A clustered index will actually rearrange the physical rows within the table. A non-clustered index will not affect the physical storage. ORDER BY clauses still work the same. Clustered indexes are useful where you often select a large number of rows from the index. The query optimiser will the perform a full table-scan as it's more efficient.
conflicted |
Conflicts resolved. |
LGTM |
Deprecates #297