-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
adding paging to get repositories from the database #1793
Conversation
Running it here this solution solves the 999 limit to me. |
Thanks @thiago LGTM and works for me as well. I do think we should consider moving about from an "IN" clause and using the temp inner join like what's mentioned in http:https://www.xaprb.com/blog/2006/06/28/why-large-in-clauses-are-problematic/ it would probably speed things up on orgs that have large repos :) |
@@ -8,6 +8,7 @@ type Feed struct { | |||
Name string `json:"name" meddler:"repo_name"` | |||
FullName string `json:"full_name" meddler:"repo_full_name"` | |||
|
|||
Id int `json:"id,omitempty" meddler:"build_id,zeroisnull"` |
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.
perhaps we sort on Created
instead since we already have the field available?
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.
Yes, i dont know why did it! 😊
To be fair this is from 2006 which may not account for 10 years of mysql or postgres optimizations.
Is there any indication that this is currently a performance bottleneck? From my testing with pretty large datasets on a relatively small database server, the IN statement still serves hundreds of feed queries per second with 999 items in the IN statement. I can't think of any real world install that would execute hundreds of feed queries per second. You can see my performance testing and results at #1234 (comment) |
also relevant from the comments section of that post. If you are having perf issues try running ANALYZE on the database in postres or sqlite (not sure about mysql)
|
… by Feed.Created.
@@ -5,6 +5,7 @@ import ( | |||
|
|||
"github.com/drone/drone/model" | |||
"github.com/franela/goblin" | |||
"fmt" |
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.
import grouping and sorting :)
the multiple float64 allocations could be avoided with some slight re-factoring as mentioned in #1793 (comment) this code correctly calculates the number of pages
to be honest I find the changes made to I also think it would be easier to unit test ... func toList(listof []*model.RepoLite, start, limit int) ([]string, []interface{}) { ... }
// could be tested with
list := []*RepoLite{
{ ... },
{ ... },
{ ... },
{ ... },
}
placeholders, parameters := toList(list, 0, 2)
g.Assert(len(placeholders)).Equal(2)
g.Assert(len(parameters)).Equal(2)
g.Assert(list[0].FullName).Equal(parameters[0])
g.Assert(list[1].FullName).Equal(parameters[1]) |
{FullName: "bradrydzewski/drone"}, | ||
{FullName: "drone/drone"}, | ||
} | ||
_repo := []*model.Repo{ |
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.
perhaps repoList
instead of _repo
since it is an array. When I see _repo
I think it is a single repo
Thank you @bradrydzewski for the details in the comments and your patience. I think I made all considerations, let me know if not. I decided to create a new branch and perform a clear change in the master branch. If you confirm, I'll send a new pull request and close this. |
I have not found another way to perform the tests in the paging function GetRepoListOf without using loop, since the limit is not configurable. Perhaps it makes sense to make the limit a global setting as |
Did I do something wrong? Sorry my anxiety.. |
EDIT: retracting comment. Looks like you made the requested changes in a different branch. Do you want to open a new PR from that branch? thanks ! :) |
Yes, after analyzing the previous reviews I thought it best to implement a new branch to make the changes clearer in the master branch. But I'd like you validate it before I submit a new PR, is it possible? Thanks! =D |
…_queries' into remove_limit_repos
Just checking in on this PR. I was speaking with @josmo a few days ago about it's status and ways to test and verify the paging and everything is working. Is there anything I could prospectively do to help push the priority up on this PR? (It's one we'd get great use out of for some customers, since they're in the gazillion repo range) . // @thiago @bradrydzewski Thanks all! 👍 |
Resolve #1776.
Related PR: #1777 #1783