gerby-project / gerby-website

Tag-based webview of LaTeX documents
MIT License
28 stars 22 forks source link

Performance issue: chapter pages #65

Closed pbelmans closed 6 years ago

pbelmans commented 6 years ago

Right now the chapter page for chapter 10 (Commutative algebra, tag 00AO (mind the spelling!)) is a bit slow. We hoped that implementing JOINs would improve this, but it seems that it doesn't.

We need to look into this at some point.

pbelmans commented 6 years ago

Maybe it's a good idea to use the backref option for the extras columns? Not sure how this falls on the "Avoiding N+1 queries".

pbelmans commented 6 years ago

I tried this. It's not helping (but it would make the code cleaner).

pbelmans commented 6 years ago

The solution with tag.slogan_set (etc.) causes lots of queries to be executed inside the Jinja template (see templates/macros.html).

  1. I don't even know what is going on here: how is the variable .slogan_set initialised to a query?
  2. Putting that entire macro in a comment gives a significant speedup. So the JOIN isn't doing what it's supposed to do, or using this .slogan_set is not using the information in the JOIN.
pbelmans commented 6 years ago

Okay, found the solution (I think). With switch() on a JOIN we can actually performing a join on 1 table against multiple multiple tables.

I'll finish the implementation after dinner.