Skip to content

perf(sharing): Don't hit the "parent" path when we load all shares an…#17091

Merged
nickvergessen merged 1 commit intomainfrom
perf/16988/getSharedWith-no-path-filter
Feb 13, 2026
Merged

perf(sharing): Don't hit the "parent" path when we load all shares an…#17091
nickvergessen merged 1 commit intomainfrom
perf/16988/getSharedWith-no-path-filter

Conversation

@nickvergessen
Copy link
Member

…yway

  • Since fix(files_sharing): Fix getting shares by path #16988 the query did not use an index anymore when entering from getSharedWith() which does not have a path. It used to have $allRoomShares = true set, but now is using the else branch which chunks and does a query on parent in blocks of 1k

Before

MariaDB [oc]> EXPLAIN SELECT `parent`, `permissions`, `file_target` FROM `oc_share` WHERE (`share_type` = '11') AND (`share_with` = 'joas');
+------+-------------+----------+-------------+---------------------------------------------------------------+----------------------------------+-----------+------+-------+----------------------------------------------------------------+
| id   | select_type | table    | type        | possible_keys                                                 | key                              | key_len   | ref  | rows  | Extra                                                          |
+------+-------------+----------+-------------+---------------------------------------------------------------+----------------------------------+-----------+------+-------+----------------------------------------------------------------+
|    1 | SIMPLE      | oc_share | index_merge | share_with_index,share_type_with,share_with_file_target_index | share_with_index,share_type_with | 1023,1025 | NULL | 17445 | Using intersect(share_with_index,share_type_with); Using where |
+------+-------------+----------+-------------+---------------------------------------------------------------+----------------------------------+-----------+------+-------+----------------------------------------------------------------+
1 row in set (0.000 sec)

After

+------+--------------+-------------+------+--------------------------------------------------------------------------------------------------+--------------+---------+--------------+------+------------------------------------+
| id   | select_type  | table       | type | possible_keys                                                                                    | key          | key_len | ref          | rows | Extra                              |
+------+--------------+-------------+------+--------------------------------------------------------------------------------------------------+--------------+---------+--------------+------+------------------------------------+
|    1 | PRIMARY      | <subquery2> | ALL  | distinct_key                                                                                     | NULL         | NULL    | NULL         | 1000 |                                    |
|    1 | PRIMARY      | oc_share    | ref  | item_share_type_index,share_with_index,parent_index,share_type_with,share_with_file_target_index | parent_index | 9       | tvc_0._col_1 | 10   | Using index condition; Using where |
|    2 | MATERIALIZED | <derived3>  | ALL  | NULL                                                                                             | NULL         | NULL    | NULL         | 1000 |                                    |
|    3 | DERIVED      | NULL        | NULL | NULL                                                                                             | NULL         | NULL    | NULL         | NULL | No tables used                     |
+------+--------------+-------------+------+--------------------------------------------------------------------------------------------------+--------------+---------+--------------+------+------------------------------------+
4 rows in set (0.001 sec)

}

$shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren);
$shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren, $path === null);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was always true before: https://github.com/nextcloud/spreed/pull/16988/changes

Suggested change
$shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren, $path === null);
$shares = $this->resolveSharesForRecipient($shares, $userId, $path, $forChildren, true);

@artonge
Copy link
Contributor

artonge commented Feb 13, 2026

/backport to stable33

@nickvergessen nickvergessen self-assigned this Feb 13, 2026
@nickvergessen nickvergessen added feature: api 🛠️ OCS API for conversations, chats and participants feature: upload & shares & voice 📤🎙️ Sharing files into a chat and audio recordings performance 🚀 labels Feb 13, 2026
@nickvergessen nickvergessen added this to the 🏖️ Next Major (34) milestone Feb 13, 2026
…yway

Signed-off-by: Joas Schilling <coding@schilljs.com>
@nickvergessen nickvergessen force-pushed the perf/16988/getSharedWith-no-path-filter branch from 962ff83 to abd48fb Compare February 13, 2026 12:24
@nickvergessen nickvergessen merged commit 68db764 into main Feb 13, 2026
83 checks passed
@nickvergessen nickvergessen deleted the perf/16988/getSharedWith-no-path-filter branch February 13, 2026 13:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: api 🛠️ OCS API for conversations, chats and participants feature: upload & shares & voice 📤🎙️ Sharing files into a chat and audio recordings performance 🚀

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants