Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8123483

Sorting large tables is a lot slower if your data model does not have property accessors

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved
    • P4
    • Resolution: Fixed
    • 8
    • 8
    • javafx
    • None
    • java 8b91, os x 10.8, macbook air 2012

    Description

      This issue relates to James_D answer findings to "JavaFx tableview sort is really slow"

      http://stackoverflow.com/questions/16805845/javafx-tableview-sort-is-really-slow-how-to-improve-sort-speed-as-in-java-swing

      James_D's answer in the linked question also includes sample code to reproduce the issue. Comment out the property accessors (firstNameProperty(), lastNameProperty(), etc) in the sample to experience slow performance.

      > In this example, the Person class doesn't have any property accessors (i.e. there's a getFirstName() method, but no firstNameProperty() method). Sorting by columns has to access the value in each cell in the column via the cell value factory. When there's no property accessor, the cell value factory is going to call getFirstName() and then wrap the result in a new ReadOnlyObjectWrapper on each invocation.
      >
      > If you make sure the class representing the row data has the appropriate property accessors, then retrieving the value is much more efficient, as it merely returns a reference to the existing StringProperty.

      For 100K rows of random data, sorting without a property accessor took about 20 seconds on a 2012 MacBook Air (UI is frozen during that time). With property accessors supplied in the data model (or if you manually trigger Collection.sort on the underlying item list), the same sort executes in less than a second.

      Attachments

        Activity

          People

            jgiles Jonathan Giles
            josmithjfx John Smith (Inactive)
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: