redis / redis-om-python

Object mapping, and more, for Redis and Python
MIT License
1.06k stars 108 forks source link

Avoid Pydantic validation on search query #570

Open DennyD17 opened 9 months ago

DennyD17 commented 9 months ago

Hey! There are calls of pydantic.main.validate_model in search queries. It is very CPU-loaded operations. And especially it affects when there are huge models and queries returning many objects. It is not necessary to validate objects in search queries, just while creating and updating. Can you please remove it or add some setting to avoid it?

For me qfix is: redis_om.model.model.RedisModel.validate_primary_key = lambda x: True pydantic.main.validate_model = lambda x, y: (y, set(y.keys()), False)

DennyD17 commented 1 month ago

@slorello89 Please, have a look on it