-
Notifications
You must be signed in to change notification settings - Fork 115
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
Query building performance discussion #435
Comments
I would be very happy to have benchmarks in the CI. That would be a good way of catching performance regressions early. I'm also open to improving rendering performance by switching away from |
I had a look at the I was running into some trouble with the more complex queries in my program at work (I do data warehousing/analytics), what I found is that if I dump the generated code into postgres it runs quite quickly, but for whatever reason opaleye was taking a long time. When I profiled, most of the time was attributed to For most of my simpler queries this isn't much of a problem, but I have a few which aggregate data across multiple tables, with multiple left-joins, inner joins, and unions. Opaleye is really great because I can abstract a lot of the common behavior into query combinators, but maybe this is abusive? In any case, you can see a really rough non-working example of what I'm envisioning here: https://github.com/csasarak/haskell-opaleye/tree/bytestrings It's basically a direct copy of the existing rendering code, just with bytestring's Builder type. One thing it doesn't do is print a pretty version though. The bytestring builders have O(1) append and |
This is exactly what Opaleye is designed for so this is definitely a use case I want to perform well. Could it be possible just to rewrite the internals of I will take a look at your analysis and example later. |
That is also possible, I was looking for a render function from I will familiarize myself more with the pretty library in order to know what writing an API compatible version would look like. I'm hoping I'm understanding what's happening correctly. |
You may want to explore the prettyprinter library - imo it's best in class |
Thanks for the tip! I'll look too
|
Thanks @ocharles. I happy to change library if there's something with better performance. |
Hey, I apologize for not working more diligently on this. The company I was working for closed-up so I've been busy working on other things. So, anecodotally PR #436 shows a bit of a decrease in time when we switch to I have more time recently and since there's interest here I'm happy to try to help out if you like. I have a few very simple benchmarks which might be useful here: https://github.com/csasarak/haskell-opaleye/tree/bench |
Great, it would be good to get some more insight into what is causing the slow performance. |
Investigations so far:
This could be tougher than we think! |
Is it possible that generating the SQL expression tree from the PrimQuery expression tree is the thing that is taking a lot of time, and it is wrongly being attributed to |
I don't think so, but I'll play around with deepseq and see if giving that a fully evaluated thing to print changes anything |
I think in view of #476 this issue should be re-opened. Probably prepare if for Hackoberfest so that we can tackle this as a community and get it fixed once and for all. |
Migrating from #434
The text was updated successfully, but these errors were encountered: