Java WEB paging

-1

I have an application developed in Java Web and I need to know what is the best way to page registration in the grid and if, depending on how it was developed, I can have performance problems as a parameter of "Date" and if this can influence when exporting a report in .CSV.

Do I paginate in the application itself or using the database?

    
asked by anonymous 23.06.2017 / 19:34

1 answer

1

Your question is very generic / wide so you can not give a very concrete answer.

In this way, some observations / answers follow, all assuming that it has no defined technology:

  

Do I paginate in the application itself or using the database?

I would do paging in the database.

The view sends the information of which page is and how many rows are to be fetched and the bank performs this operation. I would hardly load everything on the view and only page in the view. I would do this only in cases where the volume of data was extremely low and it would not increase as time went by.

  

Can I have performance issues as a "Data" parameter?

No. Unless you do multiple format conversions, sorting, and so on.

  

Can this influence when exporting a report in .csv?

Doing the pagination in the database, at the time export, then you should do a query to return everything from the database, because if you export what is being displayed, well, it will only export what is being displayed hehe. When running the "whole query" on the database, it will obviously take a little longer to retrieve the data, but it will work.

If the volume of data is too large, you should do some flushs during export. Flush is the action of transferring the data from memory to the file itself, because if you keep everything in memory and the volume of data is high, one hour you will probably get a OutOfMemoryError or something of that type.

For reference only, here is documentation of method flush() of class OutputStream which explains, in detail, what is done.

    
23.06.2017 / 20:08