Skip to content

Recomputing validation function (and methods) on every validating call #3

@tohagan

Description

@tohagan

I've just had chance to walk through all the code in this plugin and if I read the code correctly I think the current implementation will incur an unnecessarily large performance penalty on every validating call as on every call it reloads all the _design objects from the local database and recompiles the validation functions. Of smaller performance impact is that it also calls method() to rebuild the set of method on the database when it really only need one of them.

In reality, validation functions in the database are very rarely modified (except during development) so it would make more sense to cache a db.validation() function with each database instance. The plugin would then rebuild this cached function if unset for each PouchDb instance. If required the app can also watch db.changes() and clear this cache function if a design doc is updated. I think this would significantly improve validation performance.

I suspect that you might have the same issue for the other related plugins.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions