我有三个实体Recipe:RecipeIngredient和Ingredient。每个Recipe都有很多RecipeIngredients。每个RecipeIngredient人都有一个Ingredient。我的RecipeAdmin包含一个用于编辑的集合字段RecipeIngredients。集合字段包含许多表单,每个表单对应一个RecipeIngredient。此表单包含一个实体字段,用于选择Ingredient. 问题是当我RecipeIngredients在表单上有 80 个时,Symfony 会进行 80 个相同的查询,每个字段一个。
这些查询基本上看起来像:
SELECT (all the fields) FROM recipe_ingredients ORDER BY name
重要的是一切都是一样的。我认为这不正常,我该如何优化以便只需要一个查询?