Search code examples
sqloptimizationquery-optimizationibatis

ibatis query gives many results but only one is needed


I am optimizing database usage on ibatis SQL queries. I have a situation where the query results many entries but only one of them is needed. QueryForList gives too much extra information through the slow connection and QueryForObjectis not working if result is not unique. How I should do this?

I don't wanna use the list.get(0) with QueryForListif I just can omit transfering the unnecessary data.


Solution

  • You can limit result set to only one row by adding 'LIMIT 1' to your sql query.