If it's a desktop application, it will consume a lot of memory to display 1 million data in the table (or would you say, JTable), and then the application might crash due to out of memory exception.
For this reason, everyone should implement paging to all kind of data display. PHP MyAdmin is a good example for this. If the application is a desktop application, a proper calculation has to be done to determine how many rows can be display on the screen, so only the displayed data will be retrieved. And whenever the user is doing scrolling at the table, another set of data will be retrieved based on the calculation of which rows the user is displaying now if he was scrolling up/down for how many times.
For the retrieval, below is the query syntax comparison for MySQL and PostgreSQL. First query is the retrieval of 1st - 10th row, second query is for 11th - 20th row.
1. MySQL
SELECT select_list FROM table_expression LIMIT 0, 10SELECT select_list FROM table_expression LIMIT 10, 10
2. PostgreSQL
SELECT select_list FROM table_expression LIMIT 10 OFFSET 0SELECT select_list FROM table_expression LIMIT 10 OFFSET 10
Unfortunately, MSSQL and Oracle don't have the "offset" feature, and thus implementing such kind of paging will need ugly subquery that will take a long time to execute, or helper "view" that will slower the performance when inserting data. So in this case, it's to be considered whether the efficiency of data displaying is very important to the application or not.
No comments:
Post a Comment