playframework / playframework/play1

Poor model save performance due to cascade change in 1.5.0 (probably)?

Open
#1,283 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.6k
Forks
671
Avg merge
12d 15h
Merged PRs (30d)
1

Description

Is anyone else experiencing poor model save() performance? It seems to start happening when you get past a certain number of objects (hundreds) reachable by OneToMany or other relationships. In v1.4.4 and previous I do not think this was an issue, but we're seeing some requests time out because of this now (i.e. save() calls taking upwards of 30 seconds to complete).

I suspect it may have something to do with part of the change in #1113 but I'm not familiar enough with the saveAndCascade() code to be sure.

Right now our somewhat sad workaround is to add this method to most model objects and call it instead:

    public void fastSave() {
        String dbName = JPA.getDBName(this.getClass());
        if (!em(dbName).contains(this)) {
            em(dbName).persist(this);
            PlayPlugin.postEvent("JPASupport.objectPersisted", this);
        }
        willBeSaved = true;
    }

P.s. So glad to see people still working on Play 1! It's still my favorite web framework by far. Thank you!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the saveAndCascade() code and the changes discussed in #1113, then compare its behavior with the reported fastSave() workaround. Reproduce save() with hundreds of objects reachable through OneToMany or other relationships and measure whether the operation still takes over 30 seconds or times out.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
database
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.