Home > Back-end >  Mybatis database query time is too long
Mybatis database query time is too long

Time:11-19

For the first time to use mybatis, according to the online has realized to the operation of the database instance and official document, but a simple query actually took five or six seconds, that can't endure


The following is a relevant code
ProjectMapper mapper=MybatisUtils. GetSession (). GetMapper (ProjectMapper. Class);
Project project2=mapper. SelectByPrimaryKey (1);

Public static SqlSession getSession () {
SqlSessionFactory factory=getFactory ();
SqlSession session=factory. OpenSession (true);
Return the session.
}

Public static SqlSessionFactory getFactory () {
Try {
Reader Reader=Resources. GetResourceAsReader (" mybatis - config. XML ");
SqlSessionFactory factory=new the SqlSessionFactoryBuilder is (). The build (reader);
Return the factory.
} the catch (IOException e) {
e.printStackTrace();
return null;
}
}

Is this code takes too long, what reason is this excuse me? What's the solution?

CodePudding user response:

CodePudding user response:

SQL statements? How long will it take to get to look at the first directly in the client side

CodePudding user response:

refer to the second floor youxiaoyue response:
SQL statements? How long will it take to get to look at the first directly in the client side


Database on this machine is a millisecond, the database on the server to become like this, is it network problem? I this speed can also ah

CodePudding user response:

I also am this problem, I was using a cloud database, using hibernate check data, every time is 80 milliseconds, with mybatis, every time is more than 3 seconds, and that's what mybatis performance?
  • Related