Behind prefetch

Posts   
 
    
orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 07-Aug-2005 08:13:12   

Hi Frans,

I've noticed the queries performed when using the prefetch option in Adapter, and I had some questions. I'll describe my case: 3 tables - Country, City, School - where each country has more than one city (each city belongs to one country) and each city has more than one school (each school belongs to one city). I am fetching the CountryEntity object and below the queries performed: 1. SELECT COUNTRY.ID, COUNTRY.NAME FROM COUNTRY 2. SELECT CITY.ID, CITY.NAME, CITY.COUNTRY_ID FROM CITY WHERE (CITY.COUNTRY_ID IN (SELECT COUNTRY.ID FROM COUNTRY)) 3. SELECT SCHOOL.ID, SCHOOL.NAME, SCHOOL.CITY_ID FROM SCHOOL WHERE (SCHOOL.CITY_ID IN (SELECT CITY.ID FROM CITY WHERE (CITY.COUNTRY_ID IN (SELECT COUNTRY.ID FROM COUNTRY)))) Now, it's good to know that the number of the queries is the minimum required, but my problem is with the the sub-queries. For example, I find the where caluse in query no. 2 unnecessary, since CITY.COUNTRY_ID is a FK referencing COUNTRY.ID....and same thing for query no. 3.....

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 07-Aug-2005 10:53:32   

Yes this is a known issue and will be addressed in 1.0.2005.1, the upcoming upgrade simple_smile The code is now not considering this optimization.

Frans Bouma | Lead developer LLBLGen Pro
orenpeled
User
Posts: 53
Joined: 25-Jul-2005
# Posted on: 07-Aug-2005 12:46:33   

OK, thank you very much