0

calls of getSize() in impl of AbstractListModel significantly decrease performance

asked 2023-11-10 21:21:37 +0800

KlimDM gravatar image KlimDM
1

updated 2023-11-10 21:22:02 +0800

Here is my code for getSize() method:

    @Override
    public int getSize(param1, param2) {
        return <database query result>;
    }

Parameters in method call are filters, so when executing code in viewModel with implementation of AbstractListModel, this method is being called many times every time executing a query to a db. Thus, with ~26000 rows in table, it takes about 10 min for a page to render.

Is there any way to overcome this problem (maybe make zk not to call getSize() so often)?

delete flag offensive retag edit

1 Answer

Sort by » oldest newest most voted
0

answered 2023-11-14 17:57:28 +0800

hawk gravatar image hawk
3205 1 5
http://hawkphoenix.blogsp... ZK Team

updated 2023-11-14 18:00:42 +0800

When you do the query initially to get data from a database, you can store the size of the query result in your custom ListModel. Then you can just return the size without re-query every time.

@Override
public int getSize() {
    return totalSize;
}
link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2023-11-10 21:21:37 +0800

Seen: 6 times

Last updated: Nov 14

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More