feat: Add server-side search and pagination performance improvements
Summary
This PR introduces server-side search functionality and several performance improvements to the Notes app, particularly for users with large note collections. The changes focus on optimizing the initial load time and implementing efficient pagination.
Related Issues
Fixes #1226 - Notes are not loading (user has ~5k notes). HTTP 504 Gateway Timeout
Addresses #966 - Notes search is very slow via global search
Possibly fixes #1407 - On web editor, notes loading forever and impossible to show/edit
Changes
Performance Improvements
- Optimize initial notes loading by excluding content field when not needed, reducing payload size
- Implement incremental pagination for notes list scrolling to load notes in chunks
- Implement chunked API loading to prevent fetching all notes on scroll
- Fix rapid-fire pagination causing all notes to load unnecessarily
Server-Side Search
- Add server-side search with pagination support allowing filtering notes by title on the backend
- Search is case-insensitive and integrated with the existing pagination system
- Includes category statistics and total count headers for better UI feedback
Bug Fixes
- Return full note metadata for pruned notes in paginated API instead of just IDs
- Prevent periodic refresh from overwriting search results to maintain UX during active searches
- Add comprehensive logging for debugging pagination issues
Modified Files
-
lib/Controller/Helper.php- Added search parameter and filtering logic -
lib/Controller/NotesApiController.php- Integrated search with pagination, added category stats headers -
src/App.vue- Updated note loading logic -
src/NotesService.js- Enhanced service layer for pagination and search -
src/components/NoteRich.vue- UI adjustments -
src/components/NotesView.vue- Scroll-based pagination handling -
src/store/notes.js- State management for paginated notes -
src/store/sync.js- Sync improvements
Testing
Tested with large note collections (1000+ notes) to ensure:
- Initial load is significantly faster
- Pagination works smoothly during scrolling
- Search filters work correctly with pagination
- No duplicate notes or missing notes during pagination
- Addresses the 504 Gateway Timeout issue reported in #1226 for users with 5000+ notes
This PR was generated with the help of AI, and reviewed by a Human
Hi friendly ping @enjeck @JuliaKirschenheuter is there interest in this PR?
Without these changes, it take about 12 seconds for the initial page load. With this, that time is halved
Actually, I take this back. I tested again and there doesn't seem to be any consistent speedup. What sort of testing did you do on your side to show that these changes improve performance?
Hi @enjeck - I tested this locally by creating 6k notes and then testing how long it took to trigger the next-page scroll capability. I didn't compare initial page load in isolation - only the time it takes to scroll through successive pages. On large numbers of notes, the initial page load would timeout without this change. I will try to gather some more profiling information and get back to you
Hi @enjeck - I tested this locally by creating 6k notes and then testing how long it took to trigger the next-page scroll capability. I didn't compare initial page load in isolation - only the time it takes to scroll through successive pages. On large numbers of notes, the initial page load would timeout without this change. I will try to gather some more profiling information and get back to you
It would help to see a comparison of the before vs after. I used Chrome browser's Network and Performance tab to track and didn't see any noticeable difference