Hello foru,
I'm developing a applicationwith entities as Client, Client has destination addresses, each address has a Country, etc...
So, I've installed the application in the customer computer, so he has a loot of data in your database. When I want to open a form in order to list the clients, it takes a long time, around 15 seconds.
We have generated a trace in our database system and we have captured this trace:
Quote:
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2684'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 30'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2683'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2682'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2681'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 16'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2680'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2679'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2678'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2677'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2676'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 40'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2675'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 45'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2674'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2672'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2671'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2670'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 43'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2669'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2668'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT provincia0_.CODPROVI as CODPROVI9_0_, provincia0_.NOMPROVI as NOMPROVI9_0_ FROM PROVINCI provincia0_ WHERE provincia0_.CODPROVI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 17'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2667'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2666'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2665'
go
exec sp_reset_connection
go
exec sp_executesql N'SELECT direccions0_.CODCLI as CODCLI__1_, direccions0_.IDDIRENT as IDDIRENT1_, direccions0_.IDDIRENT as IDDIRENT1_0_, direccions0_.NOMENT as NOMENT1_0_, direccions0_.CODCLI as CODCLI1_0_, direccions0_.NUMDIR as NUMDIR1_0_, direccions0_.CODPAIS as CODPAIS1_0_, direccions0_.CODPROVI as CODPROVI1_0_, direccions0_.DIRENT1 as DIRENT7_1_0_, direccions0_.DIRENT2 as DIRENT8_1_0_, direccions0_.DTOENT as DTOENT1_0_, direccions0_.POBENT as POBENT1_0_, direccions0_.DEFECTO as DEFECTO1_0_ FROM DIRENT direccions0_ WHERE direccions0_.CODCLI=@p0', N'@p0 nvarchar(4000)', @p0 = N' 2663'
go
exec sp_reset_connection
go
As you can see, each time hibernate wants to fetch a entity requires open a connection operation, and when the entity is fetched hibernate closes the connection.
So my customer has a 3000 customer, 2000 addresses, 100 countries --> 3000 * 2000 = 5000 open/close connection operations.
How Can I to modify this behaviour?
I would like hibernate open connection, fetches all entities and closses the connection.
Thanks for all in advanced.