Open dev-nomi opened 3 months ago
Hi,
Yes, there will be a performance impact because you're creating an array serializer repeatedly. In my codebase, we do this in some cases where it's acceptable performance-wise, but in other cases, we avoid it because it becomes too slow. I suggest running benchmarks with your data to determine if the performance hit is acceptable for your use case.
If the performance impact is too high, unfortunately, Panko doesn't currently provide a built-in solution to handle this efficiently. However, you can use a workaround like adding a method to your model, for example:
def questions_instructions_for_serializer
return [] unless photo_choice_question?
question_instructions
end
Then you can use questions_instructions_for_serializer
as a has_many
alias.
Currently, dynamic exclusions aren't supported, and adding such a feature would require significant effort without resorting to workarounds.
Hope this helps!
Thanks, it helps alot
Hey! I have a question regarding the performance implications for conditionally including a has_many association using
Panko::Serializer::SKIP
. Specifically, I am usingPanko::ArraySerializer
in the following implementation:Questions:
Panko::ArraySerializer
in this context? Specifically, how does it affect serialization performance, especially with large sets of question_instructions?Thank you!