This site uses cookies to deliver our services and to show you relevant ads and job listings.
By using our site, you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service.
Your use of Stack Overflow’s Products and Services, including the Stack Overflow Network, is subject to these policies and terms.

Join us in building a kind, collaborative learning community via our updated
Code of Conduct.

I see that you have enabled SQL log in the hibernate config. What happens when you run the generated query on your table ? Do you still find slowness ? Do you have a better query that you can use in place of HQL ?
– Ramachandran.A.GSep 8 '16 at 3:42

1

if the order by field is not indexed, this could become very slow
– holtcSep 8 '16 at 3:58

@Ramachandran, If I run the SQL query outside Hibernate, the result is instantly displayed, it really is very fast. I have no better query, since it is very basic (ask to base all records). That's what surprises me, because if I do it with JSF templates unused Primefaces, paging is excellent.
– Gustavo EcheniqueSep 9 '16 at 0:26

This helps in attaining the connection quickly from the pool. Avoids time to get the connection.

If you have huge data, Please mark the respective column in JPA class with @OrderBy.

Hibernate search provides @SortableField to annotate the field, This indexes internally and helps in retrieving the sorted results.

[EDIT]

If Integer nroaccionista is primary key, it is indexed by default. Mark the column in JPA class with @Id and the DDL creation statement generated with create the index by default. Indexed column helps in better search and sort results.

I was trying to create a connection pool with C3P0 with the parameters you passed me in your post, I also created a connection via JNDI to glassfish, but the results are the same. The column NroAccionista the PK, so it is indexed. I can not understand where the problem is.
– Gustavo EcheniqueSep 9 '16 at 3:35

@user3624506, If server is your localhost, open JVisualVM and connect to the local server and analyse the thread dump as where the call stack is occupying more memory and processing time. This gives you complete idea of how you can reduce the time and space complexity.
– VinayVeluriSep 9 '16 at 4:38

You are using the DriverManagerConnectionProvider which only provides a rudimentary connection pooling solution. Better use HikariCP since it's the fastest one, and it's also available in Hibernate 4.3.

Related to your statement:

The problem arises with the performance of Hibernate, which is very
poor, especially considering that the table contains only 36000
records.

On each page change takes about 6 or 7 seconds.

Why would you want to fetch 36k records in a single shot?

You can't display them into a UI? That's why we have pagination after all.

Even for a batch processor, you are better off splitting the whole workload into multiple smaller data sets that allow you to keep database transactions small, and even split the load among multiple worker threads.