Skip to content

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

Merged
merged 1 commit into from
Jan 6, 2017
Merged

Create missing database indexes #596

merged 1 commit into from
Jan 6, 2017

Conversation

andreynering
Copy link
Contributor

Deprecates #297

@andreynering andreynering added the type/enhancement An improvement of existing functionality label Jan 5, 2017
@appleboy
Copy link
Member

appleboy commented Jan 5, 2017

LGTM

@tboerger tboerger added the lgtm/need 1 This PR needs approval from one additional maintainer to be merged. label Jan 5, 2017
UpdatedUnix int64
HasRecentActivity bool `xorm:"-"`
HasUsed bool `xorm:"-"`
UpdatedUnix int64 `xorm:"INDEX"`
Copy link
Member

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"`
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Contributor Author

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. 😃

Copy link

@KangoV KangoV Jan 6, 2017

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.

@lunny lunny added this to the 1.1.0 milestone Jan 6, 2017
@lunny
Copy link
Member

lunny commented Jan 6, 2017

conflicted

@andreynering
Copy link
Contributor Author

Conflicts resolved.

@lunny
Copy link
Member

lunny commented Jan 6, 2017

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 6, 2017
@lunny lunny merged commit 84b7d29 into go-gitea:master Jan 6, 2017
@andreynering andreynering deleted the gitea/create-database-indexes branch January 6, 2017 15:32
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants