Skip to content

Create missing database indexes #297

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

Closed
wants to merge 1 commit into from
Closed

Create missing database indexes #297

wants to merge 1 commit into from

Conversation

andreynering
Copy link
Contributor

Part 1 of #180

@andreynering andreynering added the type/enhancement An improvement of existing functionality label Nov 28, 2016
@andreynering andreynering added this to the 1.1.0 milestone Nov 28, 2016
@strk
Copy link
Member

strk commented Nov 28, 2016

Should migrations be written to add indexes where missing ? (I don't know how XORM works, maybe @lunny can answer this)

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Nov 28, 2016
@andreynering
Copy link
Contributor Author

@strk I am also confused by how migrations work on Gogs/Gitea, but I discovered that by simple adding/changing fields it syncs automatically on initialization.

@tboerger
Copy link
Member

Do we really need only these single index definitions? Or do we also need combined index definitions?

@lunny
Copy link
Member

lunny commented Nov 29, 2016

@andreynering database migration by two methods, one is xorm.Sync2(). It will automatically add new fields, and modify indexes. Another is migrations, it lets us manually write some functions to do migrations.

@andreynering
Copy link
Contributor Author

Thank you for explaining @lunny I have to learn more of Xorm.

@tboerger I think I didn't add an index where an composite index existed before. If I did I'll update.

Some indexes may be not needed today, but I think foreign keys and timestamps should always have. Any column we may need to use in WHERE or ORDER BY in future its useful to have an index.

@tboerger
Copy link
Member

IMHO we need to analyze the queries to see where composite indices make sense.

@lunny
Copy link
Member

lunny commented Dec 24, 2016

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Dec 24, 2016
@tboerger
Copy link
Member

Any update? Have you checked if we need some composite index?

@andreynering
Copy link
Contributor Author

@tboerger Not yet, will do.

But when in doubt single column indexes are better, because databases can merge multiple indexes when necessary, but can't use a composite index when not all columns are given on WHERE.

@andreynering
Copy link
Contributor Author

@tboerger I would not change any index to a composite index.

@strk
Copy link
Member

strk commented Jan 5, 2017

This needs a rebase (was about to test it but got blocked there)

@andreynering
Copy link
Contributor Author

Deprecated by #596

@KangoV
Copy link

KangoV commented Jan 6, 2017

How will this affect gogs->gitea migration? I take it the indexes will not get created if the db already exists?

@lunny
Copy link
Member

lunny commented Jan 7, 2017

No. It will automatically migration from Gogs -> Gitea. This is a feature of XORM when call x.Sync2().

@KangoV
Copy link

KangoV commented Jan 7, 2017

@lunny That's cool. I am currently a Java dev with a lot of Experience with Hibernate/Cassandra/PostgrSQL etc. I do not know much about XORM yet.

@lunny
Copy link
Member

lunny commented Jan 8, 2017

You can find the document here http://gobook.io/read/github.com/go-xorm/manual-en-US/

@tboerger tboerger removed type/enhancement An improvement of existing functionality lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Jan 16, 2017
@tboerger tboerger removed this from the 1.1.0 milestone Jan 16, 2017
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
@delvh delvh added the issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea label Oct 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
issue/not-a-bug The reported issue is the intended behavior or the problem is not inside Gitea
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants