Database Performance with WASP
I'm currently studying about the wasp solution to insert in one solution of my startup
I saw that when you do any action like update a model name, for example, it load all the entity data
If i have a relationship between two tables and list with any join, changing the entity will make load all the queries?
1 Reply
Hi @Kbral. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Based on the provided knowledge sources, I can offer some insights into your question about database performance with Wasp, particularly regarding query invalidation and caching. However, it's important to note that the information available doesn't fully address all aspects of your specific scenario.
Wasp uses an automatic Entity-based Query cache invalidation system. According to the Wasp documentation on Cache Invalidation, when an Action that uses a particular Entity is executed, it invalidates the cache of all Queries that use the same Entity. This is designed to keep the data fresh without requiring manual cache management.
In your scenario, if you update a model name (which I assume is an Action that modifies an Entity), it would indeed invalidate the cache for all Queries that use that Entity. This means that those Queries would refetch data from the server to update their results.
Regarding your question about relationships between tables and joins, the knowledge sources don't provide specific information about how Wasp handles this situation. However, based on the general behavior described, if your list query involves a join between two Entities, and you modify one of those Entities, it's likely that the query's cache would be invalidated, potentially causing a reload of all the data.
It's worth noting that while this automatic invalidation is convenient, it can potentially lead to performance issues in larger applications. The Wasp team is aware of this limitation, as mentioned in the tutorial documentation:
"This behavior is convenient as a default but can cause poor performance in large apps. While there is no mechanism for overriding this behavior yet, it is something that we plan to include in Wasp in the future."
For now, if you're concerned about performance in scenarios with complex relationships or large datasets, you might need to consider manual cache management strategies or optimize your data fetching patterns. The Wasp team is actively working on improving these aspects, as evidenced by ongoing discussions in their GitHub issues.
Remember, while Wasp's current approach aims for simplicity and automatic updates, it may not be optimal for all use cases, especially those involving complex data relationships or large-scale applications. As you're considering Wasp for your startup, you might want to evaluate how this behavior aligns with your specific performance requirements.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Kbral, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?