France-ioi / AlgoreaBackend

Backend for the new Algorea platform
MIT License
1 stars 2 forks source link

Fix slow start result path #1061

Closed GeoffreyHuck closed 3 months ago

GeoffreyHuck commented 3 months ago

fixes #1050

The query is very weird (and still is).

We already know the path, it's given in the URL. We need only to know if it's valid.

The written query seems to do something else: finding all possible paths and then matching the path we want.

So I added the constraints of the path in the query (visible_items restricted to the ids in the path, we don't need ALL visible items of the current user), and set the ids of the items in the path, because we know them.

We can probably do even better by rewriting the query, if we need to, because it's confusing.

It takes ~1s now on preprod.

Still no clue about the difference between prepared query and directly query ran directly

Still no clue. Today the query took longer even in console. I ran ANALYZE TABLE xxx recently on some tables, maybe it's related, but then it should be faster, not slower. BUT I did EXPLAIN on the two, and the result is different: prepared queries can have a different execution plan than queries run directly.

Even with the EXPLAIN I still couldn't find exactly what was so slow.

codecov[bot] commented 3 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 100.00%. Comparing base (c13c47a) to head (6111074).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1061 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 236 236 Lines 14226 14229 +3 ========================================= + Hits 14226 14229 +3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.