Look up a table having 1 million records using Hibernate
===

My database table(geo ip lookup) is having 7 columns,of which 2 columns constitute < composite-id>.
Now when i lookup for a value using first 2 coloumns it takes me **12-14 seconds** to fetch a record..

My DAO code looks like this:

    String queryString = "from Igeo igeo where igeo.ip_from <= " + ip
				+ "and igeo.ip_to >= " + ip;

		Query q = session.createQuery(queryString);
		List<Igeo> igeoList = q.list();

		if(igeoList.size() > 0){
			Igeo igeo = igeoList.get(0);

			ISP = igeo.getIsp();
			...
            ...			
		}

*Igeo = class in java represnting table

**Record is fetched when ip lies between values of composite-id columns eg.

ip_from = 1 ; ip_to = 3 ; ip = 2;

so above row will be returned

This table is only used to read records ,please suggest me a queryString which is more efficient than above