Repository navigation
Conversation
9b6bd68 to
4033598
Compare
enhanceTables for a multiple tables at once to get rid of N+1 queries29cbb47 to
44e315b
Compare
2686136 to
e9b83fb
Compare
e9b83fb to
b286459
Compare
306f894 to
f5cb044
Compare
a7383f5 to
c9e19d1
Compare
263e65c to
ba01275
Compare
ba01275 to
ecef56b
Compare
7243f39 to
e845c15
Compare
blizzz
left a comment
There was a problem hiding this comment.
Some questions, and view ordering got lost it seems
| * @param array<int, int|null> $tableRowsCounts | ||
| */ | ||
| private function enhanceViews(array $views, string $userId, array $tableRowsCounts = []): void { | ||
| if (empty($views)) { |
There was a problem hiding this comment.
this does not have the isFederated guard anymore. Intentional? It puts the responsibility to check about it to the caller, like in enhanceView() currently.
There was a problem hiding this comment.
I've added behat test for that, please check
|
|
||
| try { | ||
| $excluded = !$this->circleHelper->isCirclesEnabled() ? [ShareReceiverType::CIRCLE] : []; | ||
| $shares = $this->mapper->findAllSharesForNodes('table', $tableIds, $userId, $excluded); |
There was a problem hiding this comment.
Does this still find all shares for a table manager, i.e. indirect shares?
There was a problem hiding this comment.
I've added behat test for that, please check
e845c15 to
ecef56b
Compare
ecef56b to
abc0f82
Compare
ef7479b to
e460edf
Compare
|
@blizzz I've fixed code review comments, please check |
e460edf to
b5cf342
Compare
…N+1 queries Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
…N+1 queries (code review new portion) Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
…N+1 queries (more tests) Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>
b5cf342 to
70976c6
Compare
enjeck
left a comment
There was a problem hiding this comment.
I have some more comments:
| try { | ||
| $allViews = $this->mapper->findAllByTableIds($tableIds); |
There was a problem hiding this comment.
findForTables() dropped the canManageTable() check from the old findAll(). I think this causes a read-only sharee calling GET /api/2/tables/scheme/{id} gets 200 with all views and their filters ??
| public function getScheme(int $id, ?string $userId = null): TableScheme { | ||
| $table = $this->find($id, skipTableEnhancement: true); | ||
| $columns = $this->columnService->findAllByTable($id, null, $table); | ||
| $this->enhanceTable($table, $userId ?? ''); |
There was a problem hiding this comment.
Should this be preCheckUserId($userId) instead?
| try { | ||
| $this->enhanceTables($allTables, $userId); | ||
| } catch (InternalError|PermissionError $e) { | ||
| $this->logger->error($e->getMessage(), ['exception' => $e]); |
There was a problem hiding this comment.
One exception here now skips enhancement for every table. Can each step handle its own errors like before?
| $this->logger->warning('Exception occurred: ' . $e->getMessage() . ' Returning 0.'); | ||
| return 0; | ||
| $counts = array_fill_keys($tableIds, 0); | ||
| foreach (array_chunk($tableIds, 1000 - 1) as $tableIdsChunk) { |
There was a problem hiding this comment.
Can we build the query once outside the loop and use a DB_CHUNK_SIZE constant?
| * @param int[] $tableIds | ||
| * @return int[] | ||
| */ | ||
| public function findLinkSharesForTables(array $tableIds): array { |
There was a problem hiding this comment.
| public function findLinkSharesForTables(array $tableIds): array { | |
| public function findTableIdsWithLinkShares(array $tableIds): array { |
| * @return array<int, int> | ||
| * @throws InternalError | ||
| */ | ||
| public function countSharesForTables(array $tableIds): array { |
There was a problem hiding this comment.
This duplicates countSharesForViews(). Could they merge into one countSharesForNodes($nodeType, $nodeIds)? Or is that too hard ?
In our organization we operate a large amount of tables/views, so there are performance bottleneck here:
TableService::enhanceTable()in a loop with a single call of theenhanceTables()ViewService::enhanceView()in a loop with a single call of theenhanceViews()UserHelperfor row/column counts, share counts and owner display names.🖼️ Screenshots
Here profiler results for
GET /apps/tables/tableendpoint for 18 tables and 9 views:🏁 Checklist
/backport to stableX.X🤖 AI (if applicable)