DocumentViewSet.get_queryset() carried a blanket .distinct() left over from an older query shape (predating the version-file feature and the correlated-subquery rewrite of num_notes/effective_content). Nothing in the current base queryset can produce duplicate document rows: select_related is all FK-to-PK, and the permission filter is a boolean id__in predicate, not a join. id (the PK) is also always selected and inherently unique, so .distinct() was a structural no-op for correctness. It was not a no-op for cost. EXPLAIN showed it forcing a full sort-then- dedupe over the entire permission-visible document set before LIMIT could apply -- 340k rows for a 25-row page, with the effective_content/num_notes correlated subqueries re-executed once per row as a result. This was the dominant cost behind the original report's document overview slowness, well beyond the get_user_can_change N+1 fixed separately. Removing it isn't safe on its own, though -- auditing found two existing filters that rely on an M2M join *without* deduping themselves, previously papered over by the blanket .distinct(): - InboxFilter: a document with two tags both flagged is_inbox_tag=True (nothing prevents that) would be returned twice for ?is_in_inbox=true. - CustomFieldsFilter: a document with multiple custom field instances matching different OR-ed branches would be returned once per match. Fixed both locally, matching the pattern ObjectFilter already used for tags__id__in/custom_fields__id__in. Added regression tests for both -- confirmed they fail without the local .distinct() calls. Benchmarked against the same 400k-document/1,000-tag corpus: document list wall-clock for a permission-restricted user drops from ~15.8s to ~2.25s (~7x), closing most of the previous gap to a superuser's ~1.8s. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Paperless-ngx
Paperless-ngx is a document management system that transforms your physical documents into a searchable online archive so you can keep, well, less paper.
Paperless-ngx is the official successor to the original Paperless & Paperless-ng projects and is designed to distribute the responsibility of advancing and supporting the project among a team of people. Consider joining us!
Thanks to the generous folks at DigitalOcean, a demo is available at demo.paperless-ngx.com using login demo / demo. Note: demo content is reset frequently and confidential information should not be uploaded.
Features
A full list of features and screenshots are available in the documentation.
Getting started
The easiest way to deploy paperless is docker compose. The files in the /docker/compose directory are configured to pull the image from the GitHub container registry.
If you'd like to jump right in, you can configure a docker compose environment with our install script:
bash -c "$(curl -L https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/install-paperless-ngx.sh)"
More details and step-by-step guides for alternative installation methods can be found in the documentation.
Migrating from Paperless-ng is easy, just drop in the new docker image! See the documentation on migrating for more details.
Documentation
The documentation for Paperless-ngx is available at https://docs.paperless-ngx.com.
Contributing
If you feel like contributing to the project, please do! Bug fixes, enhancements, visual fixes etc. are always welcome. If you want to implement something big: Please start a discussion about that! The documentation has some basic information on how to get started.
Community Support
People interested in continuing the work on paperless-ngx are encouraged to reach out here on github and in the Matrix Room. If you would like to contribute to the project on an ongoing basis there are multiple teams (frontend, ci/cd, etc) that could use your help so please reach out!
Translation
Paperless-ngx is available in many languages that are coordinated on Crowdin. If you want to help out by translating paperless-ngx into your language, please head over to https://crowdin.com/project/paperless-ngx, and thank you! More details can be found in CONTRIBUTING.md.
Feature Requests
Feature requests can be submitted via GitHub Discussions, you can search for existing ideas, add your own and vote for the ones you care about.
Bugs
For bugs please open an issue or start a discussion if you have questions.
Related Projects
Please see the wiki for a user-maintained list of related projects and software that is compatible with Paperless-ngx.
Important Note
Document scanners are typically used to scan sensitive documents like your social insurance number, tax records, invoices, etc. Paperless-ngx should never be run on an untrusted host because information is stored in clear text without encryption. No guarantees are made regarding security (but we do try!) and you use the app at your own risk. The safest way to run Paperless-ngx is on a local server in your own home with backups in place.
