In the server side code generally for better performance we should not use \"select * from table\" rather we should query the necessary column according to the need (Select
Entity queries (e.g. JPQL, HQL,Criteria API) are again rendered back to SQL queries, so it’s evident that running a native SQL query is going to be faster than running an entity query.
However, if you set the query plan cache size right, then you could speed up entity queries so that they run as fast as SQL ones.
But if you want to benefit from the dirty checking mechanism and issue UPDATE automatically from the modified entities, then an entity query is much more convenient. As long as the time difference between an entity query and an SQL query is insignificant (which most often is if you use database indexing and the entity query renders a very efficient SQL query), there’s nothing to worry about.