Q: Tweek performance of JPA OneToMany I have following JPA entity:
Entity
@Entity
@Table(name = "todo")
@NamedEntityGraph(name = "TodoEntity.children",
        attributeNodes = @NamedAttributeNode("children"))
public class TodoEntity {

    public TodoEntity() {
    }

    @Id
    @GeneratedValue
    private Long id;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    private Long userId;

    private String text;

    private String description;

    private Boolean collapsed;

    private Boolean completed;

    private Integer sortOrder;

    private Date expiredDate;

    @CreationTimestamp
    @Temporal(TemporalType.TIMESTAMP)
    private Date creationDate;

    private Integer priority;

    private String guid;

    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
    @JsonIgnore
    @Column(updatable = false,nullable = false)
    private Long parentId;

    @OneToMany(fetch = FetchType.EAGER)
    @Cascade({CascadeType.ALL})
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name = "parentId", referencedColumnName = "id")
    @OrderBy("sortOrder ASC")
    private List<TodoEntity> children;
}

Repo
@EntityGraph(value = "TodoEntity.children", type = EntityGraph.EntityGraphType.FETCH)
    Page<TodoEntity> findByUserIdAndParentId(Long userId, Long parentId, Pageable pageable);

I want to have a TodoList that I can infinitely nest.
The code is working so far - only thing is that when I have around 1500 todos and they are nested, SQL and the queries are becoming slow (around 1,3s)
How can I improve this?

IDEA:
Actually I think it would be enough to just get all Todos in the database with one query (that takes 2,2 ms) and then nesting them with java (having the parentId) so that the workload is on the application layer. 
