-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Performance issues while coding Multitenancy in Hibernate
PostPosted: Sun Aug 21, 2016 8:19 am 
Newbie

Joined: Sun Aug 21, 2016 8:14 am
Posts: 2
We are using for implementing multi tenancy as ***separate-schema per tenant approach*** in our application using Spring data JPA with Hibernate

https://docs.jboss.org/hibernate/orm/4. ... ml#d5e4866
(note: This is also explained as Strategy 3 at following stackoverflow question link --- http://stackoverflow.com/questions/2122 ... te-and-c3p)

The problem is that while executing any query hibernate sets search path by executing a sql and same is done when connection is released. This is causing 2 extra sql execution and database round trips. While evaluating performance we found that the schema setting part is taking almost 30% of the total execution time. Is there any way we can avoid the extra sql executions for setting search path. Please note that we don't have an option to use separate connection pool for a schema


Top
 Profile  
 
 Post subject: Re: Performance issues while coding Multitenancy in Hibernate
PostPosted: Mon Aug 29, 2016 4:31 am 
Hibernate Team
Hibernate Team

Joined: Thu Sep 11, 2014 2:50 am
Posts: 1628
Location: Romania
You basically have two options for multitenancy:

1. Either you separate the database or schema at the connection pool level,

2. Or you use a single connection pool and switch the schema at runtime.

According to this StackOverflow answer, the PostgreSQL SET search_path operation should be very fast and cheap. If you experience problems with the PostgreSQL schema setting, you should address this problem on the PostgreSQL forum. Maybe it was some issue that got fixed in a later version.

Vladimir Sitnikov suggested that SET search_path invalidates the Statement cache, which might explain your performance degradation issue.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.