[Phriction] Slow / 2500x same SQL query on root page


#1

Observed Behavior:
When opening the Phriction wiki root page (partially also on nested pages, but extremely noticeable on the root) it takes very long to load the page. Using the DarkConsole I was able to see that the most time is spent with SQL queries and further looking at it I saw that the exact same query is executed ~ 2500 times.

Query:

SELECT * FROM `phabricator_policy`.`policy` WHERE phid IN ('PHID-PLCY-ab4fszy3ruacs3mu544q');
SELECT `p`.* FROM `project` p JOIN `edge` e ON e.src = p.phid AND e.type = 60 WHERE (phid IN ('PHID-PROJ-cj4jm6eo77rz7b737jus')) AND (e.dst IN ('PHID-USER-vvl2vjjqie3sfmxujj6k')) GROUP BY p.phid  ORDER BY `p`.`name` ASC;

Facts:

  • Our root page has very large amount of direct children (listed in Document Hierarchy) and links to subpages

Expected Behavior:
Loading should not take that long, the same query should not be executed 2500 times.

Phabricator Version:
phabricator
96f9b0917e21f84995d99571d6006627590d9c00 (Thu, Nov 15)
arcanist
3534d2baca4bf6dcdac46c49164bf5ba3a6660ad (Thu, Nov 8)
phutil
0e6ee5937ca5ea4378b0b701aaf7b149e8f7f58e (Thu, Nov 15)
diff
3.3 at /usr/bin/diff
git
2.13.6 at /usr/bin/git
hg
4.5.3 at /usr/bin/hg
pygmentize
2.2.0 at /usr/bin/pygmentize
svn
1.9.7 at /usr/bin/svn

Running inside a Docker container (redpointgames/phabricator:latest).

Reproduction Steps:
Create a large amount of Phriction subpages that are directly attached to the root page. On the root page itself, create many links to other pages.

Maybe enable the Spaces app as well and set custom policies for many pages.

Please let me know if more information is needed. Thanks!


#2

We are also noticing Phriction has become very slow in the last few months. I took a look at DarkConsole on the root page and it shows 1276 queries, mostly this one:

SELECT `p`.* FROM `project` `p` JOIN `edge` e ON e.src = p.phid AND e.type = 60 WHERE ((phid IN
('<project that has access to Phriction>')) AND (e.dst IN ('<user viewing the page>'))) GROUP BY `p`.phid  ORDER BY `p`.`name`
ASC 

Our root page has about 20 links and subpages, so it doesn’t necessarily have to do with having a huge number of links.

Version:

phabricator 491ba6d77e19522136e29edc23c509c96f42e47c (Sun, Jan 20) (branched from e6ca2b998fd4ba1d197322228f408b2461314659 on origin)
arcanist 97ddb9d5a1be282d6002a875a759266bb97b653f (Fri, Dec 28) (branched from 25c2381959ac94d9249ae4023c5f9ea36436b81c on origin)
phutil 8a9f4b1f806e9eff0fbf5b32cfc29842c0db3f49 (Sat, Jan 19) (branched from 92413d0303ab2f86eb397db0441b024de4099975 on origin)