codeintel: Optimize UpdateDependencyNumReferences query
Created by: efritz
This query should do the same thing but should choose a much better query plan. This should take some pressure off of Postgres as the previous query is inefficient enough to create some LSIF processing back pressure, which we generally don't encounter.
Two changes help here:
- We add a materialized cte around a select of a table to better hint at a more efficient index
- Use
UPDATE FROM
instead of a subselect, which kept scanning CTE results
I've been trying a few queries on the Cloud database and I've taken some samples down from minutes to sub-second with these changes.