Fix candidate collection for query with many Statements containing WITHs#635
Fix candidate collection for query with many Statements containing WITHs#635anderson4j wants to merge 4 commits intomainfrom
Conversation
|
…their own file and warn about limitations of the new approach
|
I had a discussion with Oskar, and we decided to put fixing the slow query on hold, since we either need to We already plan to update the ANTLR dependency at some point, so let's settle that and then reassess how this issue can be fixed |
Inspired by this PR on the db repo.
Certain queries with very many clauses caused the antlr4-c3 library to enter a deep recursion which quickly (in terms of growing query size) became very slow.
ex.
would before take more than 5 seconds to complete. Adding just a few more lines made it slower than I had patience to wait for.
Our fix finds the latest clause and uses this to modify the tokenStartIndex in the candidate collection of antlr4-c3. Doing this, we get back to normal time for candidate collection, even for queries with more than a 100 statements which before would have been completely untenable.