Skip to content

[_] fix: add parent_uuid support to folder sync queries#1040

Merged
apsantiso merged 1 commit into
masterfrom
fix/sync-folders-query-parent-uuid-null-support
Apr 17, 2026
Merged

[_] fix: add parent_uuid support to folder sync queries#1040
apsantiso merged 1 commit into
masterfrom
fix/sync-folders-query-parent-uuid-null-support

Conversation

@apsantiso
Copy link
Copy Markdown
Collaborator

@apsantiso apsantiso commented Apr 16, 2026

What

We fixed the folder sync a few weeks ago by adding a new index, but the query changed to parentUuid, so folder sync is slower again.

Let's standardize the indexes and queries to use parentUuid.

Changes

  • Changed index name and predicate
  • Changed workspace's folder listing / sync query to WHERE parent_uuid: NULL.

Benchmark

Before (index with parent_id IS NOT NULL)

Limit  (cost=18.21..18.22 rows=1 width=137) (actual time=0.190..0.192 rows=0 loops=1)
  Buffers: shared hit=6
  ->  Sort  (cost=18.21..18.22 rows=1 width=137) (actual time=0.189..0.190 rows=0 loops=1)
        Sort Key: updated_at
        Sort Method: quicksort  Memory: 25kB
        Buffers: shared hit=6
        ->  Bitmap Heap Scan on folders "FolderModel"  (cost=14.19..18.20 rows=1 width=137) (actual time=0.154..0.155 rows=0 loops=1)
              Recheck Cond: ((user_id = 10001) AND (parent_uuid IS NOT NULL))
              Filter: (updated_at > '2026-04-16 12:26:00+00'::timestamp with time zone)
              Buffers: shared hit=6
              ->  BitmapAnd  (cost=14.19..14.19 rows=1 width=0) (actual time=0.146..0.147 rows=0 loops=1)
                    Buffers: shared hit=6
                    ->  Bitmap Index Scan on user_id_folders_index  (cost=0.00..4.46 rows=4 width=0) (actual time=0.080..0.080 rows=11 loops=1)
                          Index Cond: (user_id = 10001)
                          Buffers: shared hit=3
                    ->  Bitmap Index Scan on folders_parent_uuid_index  (cost=0.00..9.48 rows=140 width=0) (actual time=0.063..0.063 rows=35 loops=1)
                          Index Cond: (parent_uuid IS NOT NULL)
                          Buffers: shared hit=3
Planning:
  Buffers: shared hit=19 read=1
Planning Time: 1.796 ms
Execution Time: 0.347 ms

After index:

Limit  (cost=0.14..8.16 rows=1 width=137) (actual time=0.079..0.080 rows=0 loops=1)
  Buffers: shared hit=1
  ->  Index Scan using idx_folders_user_parent_updated on folders "FolderModel"  (cost=0.14..8.16 rows=1 width=137) (actual time=0.070..0.070 rows=0 loops=1)
        Index Cond: ((user_id = 10001) AND (updated_at > '2026-04-16 12:26:00+00'::timestamp with time zone))
        Buffers: shared hit=1
Planning Time: 0.507 ms
Execution Time: 0.116 ms

@apsantiso apsantiso requested a review from sg-gs April 16, 2026 14:32
@apsantiso apsantiso self-assigned this Apr 16, 2026
@apsantiso apsantiso requested a review from jzunigax2 as a code owner April 16, 2026 14:32
@apsantiso apsantiso added the migration-required A migration is included in the PR label Apr 16, 2026
@sonarqubecloud
Copy link
Copy Markdown

@apsantiso apsantiso changed the title [_] fix: add parent_uuid support for sync folders queries [_] fix: add parent_uuid support to folder sync queries Apr 16, 2026
@sg-gs
Copy link
Copy Markdown
Member

sg-gs commented Apr 16, 2026

Running migration @apsantiso

@sg-gs
Copy link
Copy Markdown
Member

sg-gs commented Apr 17, 2026

Migration run @apsantiso

@apsantiso apsantiso merged commit d9495dc into master Apr 17, 2026
9 checks passed
@apsantiso apsantiso deleted the fix/sync-folders-query-parent-uuid-null-support branch April 17, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

migration-required A migration is included in the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants