-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Create missing database indexes #297
Conversation
Should migrations be written to add indexes where missing ? (I don't know how XORM works, maybe @lunny can answer this) |
@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. |
Do we really need only these single index definitions? Or do we also need combined index definitions? |
@andreynering database migration by two methods, one is |
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. |
IMHO we need to analyze the queries to see where composite indices make sense. |
LGTM |
Any update? Have you checked if we need some composite index? |
@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. |
@tboerger I would not change any index to a composite index. |
This needs a rebase (was about to test it but got blocked there) |
Deprecated by #596 |
How will this affect gogs->gitea migration? I take it the indexes will not get created if the db already exists? |
No. It will automatically migration from Gogs -> Gitea. This is a feature of XORM when call |
@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. |
You can find the document here http://gobook.io/read/github.com/go-xorm/manual-en-US/ |
Part 1 of #180