Skip to content
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

Application becomes unresponsive after entering a short query in Athena #269

Closed
alaq opened this issue Jul 17, 2020 · 7 comments · Fixed by #319
Closed

Application becomes unresponsive after entering a short query in Athena #269

alaq opened this issue Jul 17, 2020 · 7 comments · Fixed by #319
Labels
t/bug type of work

Comments

@alaq
Copy link
Contributor

alaq commented Jul 17, 2020

Problem

Entering a short query (one or two characters) in Athena will freeze the application. The only way out of it is to close the tab. You need to have data for this.

Expected Behavior

The application should remain responsive and show a list of results in Athena.

Dependencies

  • Athens: latest master
  • browser: Chromium, Firefox

To Reproduce

https://athensresearch.github.io/athens/ then load test data, input one or two characters in Athena. The application will freeze.

@alaq alaq added the t/bug type of work label Jul 17, 2020
@alaq alaq mentioned this issue Jul 17, 2020
11 tasks
@jorda0mega
Copy link
Contributor

the main issue is with the get-root-parent-node function in db.cljs. After loading the Test DB, if you type "a" the search-in-block-content function will return 1780 records. Looping through all of the children blocks of 1780 records will freeze the application. A possible solution would be to limit the query results to 20 to begin with. The code is already limiting the search results to 20 in athena.cljs

(defn get-root-parent-node
  [block]
  (loop [b block]
    (if (:node/title b)
      (assoc block :block/parent b)
      (recur (first (:block/_children b))))))

@itsrainingmani
Copy link
Contributor

@jorda0mega I think datascript has a :limit option that should allow us to limit how many search queries are returned. I'm going to test that and see what the best option is.

@jorda0mega
Copy link
Contributor

So I tried the :limit in datomic pull syntax but that's only for a many attribute. In this case I think we would need the cap the entire list of results rather than one of the attributes. Might be wrong though so let me know if it works

@itsrainingmani
Copy link
Contributor

I also tried just putting a (take 20) inside the search-in-block-content which seems to fix this issue. There is still some latency though.

https://github.com/itsrainingmani/athens/blob/a0ac5c37b9c80f117c21cb422fe98674953fc4e3/src/cljs/athens/db.cljs#L305

@jorda0mega
Copy link
Contributor

Nice. That's what I was thinking as well but I feel there has to be a way to do this at the query level

@itsrainingmani
Copy link
Contributor

I looked at the datascript source and I can't find an option for that. So maybe not.

@tangjeff0
Copy link
Collaborator

@jorda0mega I don't believe there is! The datalog query is set-based, so if there was a native limit within the query, I think it would essentially be doing the same thing as take outside the query. Different from the typical mental model of SQL dbs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
t/bug type of work
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants