B
BananaRepublic
I'm trying to understand how Jet behaves with ODBC sources. I've logged the
SQL recieved by the server and while I think that Jet acts generally
intelligently when we want to navigate a bound form or update/insert/delete a
record. It is a good citizen in those scenarios, only selecting few rows for
the navigation, and using WHERE clause to guarantee that it works with one or
few rows at a time.
However, when I open a form (in this scenario, a simple bound form with a
simple linked subform), I get several queries, which seems to be redundant.
The form's recordsouce:
Main form's recordsource: SELECT * FROM country;
Subform's recordsource: SELECT * FROM city;
Linked Fields:
(Master) Code = (Child) CountryCode
*******************Start Log***********************
071115 10:56:56 78 Connect root@localhost on world
78 Query SET SQL_AUTO_IS_NULL = 0
78 Query SELECT Config, nValue FROM MSysConf
78 Query SELECT `Code` ,`Name` ,`Continent` ,`Region` ,`SurfaceArea` ,
`IndepYear` ,`Population` ,`LifeExpectancy` ,`GNP` ,`GNPOld` ,`LocalName` ,
`GovernmentForm` ,`HeadOfState` ,`Capital` ,`Code2` FROM `country`
78 Query SELECT `ID` ,`Name` ,`CountryCode` ,`District` ,`Population`
FROM `city`
78 Query SELECT `ID` ,`Name` ,`CountryCode` ,`District` ,`Population`
FROM `city`
78 Query SELECT `country`.`Code` FROM `country`
78 Query SELECT `Code`,`Name`,`Continent`,`Region`,`SurfaceArea`,
`IndepYear`,`Population`,`LifeExpectancy`,`GNP`,`GNPOld`,`LocalName`,
`GovernmentForm`,`HeadOfState`,`Capital`,`Code2` FROM `country` WHERE
`Code` = 'ABW'
78 Query SELECT `city`.`ID` FROM `city` WHERE ( 'ABW' = `CountryCode` )
78 Query SELECT `ID`,`Name`,`CountryCode`,`District`,`Population` FROM
`city` WHERE `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` =
129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129
78 Query SELECT `country`.`Code` FROM `country`
78 Query SELECT `city`.`ID` FROM `city` WHERE ( '' = `CountryCode` )
78 Query SELECT `city`.`ID` FROM `city` WHERE ( '' = `CountryCode` )
78 Query SELECT `Code`,`Name`,`Continent`,`Region`,`SurfaceArea`,
`IndepYear`,`Population`,`LifeExpectancy`,`GNP`,`GNPOld`,`LocalName`,
`GovernmentForm`,`HeadOfState`,`Capital`,`Code2` FROM `country` WHERE
`Code` = 'ABW'
78 Query SELECT `city`.`ID` FROM `city` WHERE ( 'ABW' = `CountryCode` )
78 Query SELECT `ID`,`Name`,`CountryCode`,`District`,`Population` FROM
`city` WHERE `ID` = 129
**************End Log***************
Specific questions:
1) Why ask for a full table scans even if it already has the keys it needs?
Indeed, why ask for it multiple times?
2) Putting in TOP values does not work. Why?
3) Putting in WHERE values does seems to help in limiting the recordset, but
Jet still will try to retrieve the whole recordset. Why can't Jet just fetch
the first few rows?
4) Can I improve the behavior somehow?
TIA.
SQL recieved by the server and while I think that Jet acts generally
intelligently when we want to navigate a bound form or update/insert/delete a
record. It is a good citizen in those scenarios, only selecting few rows for
the navigation, and using WHERE clause to guarantee that it works with one or
few rows at a time.
However, when I open a form (in this scenario, a simple bound form with a
simple linked subform), I get several queries, which seems to be redundant.
The form's recordsouce:
Main form's recordsource: SELECT * FROM country;
Subform's recordsource: SELECT * FROM city;
Linked Fields:
(Master) Code = (Child) CountryCode
*******************Start Log***********************
071115 10:56:56 78 Connect root@localhost on world
78 Query SET SQL_AUTO_IS_NULL = 0
78 Query SELECT Config, nValue FROM MSysConf
78 Query SELECT `Code` ,`Name` ,`Continent` ,`Region` ,`SurfaceArea` ,
`IndepYear` ,`Population` ,`LifeExpectancy` ,`GNP` ,`GNPOld` ,`LocalName` ,
`GovernmentForm` ,`HeadOfState` ,`Capital` ,`Code2` FROM `country`
78 Query SELECT `ID` ,`Name` ,`CountryCode` ,`District` ,`Population`
FROM `city`
78 Query SELECT `ID` ,`Name` ,`CountryCode` ,`District` ,`Population`
FROM `city`
78 Query SELECT `country`.`Code` FROM `country`
78 Query SELECT `Code`,`Name`,`Continent`,`Region`,`SurfaceArea`,
`IndepYear`,`Population`,`LifeExpectancy`,`GNP`,`GNPOld`,`LocalName`,
`GovernmentForm`,`HeadOfState`,`Capital`,`Code2` FROM `country` WHERE
`Code` = 'ABW'
78 Query SELECT `city`.`ID` FROM `city` WHERE ( 'ABW' = `CountryCode` )
78 Query SELECT `ID`,`Name`,`CountryCode`,`District`,`Population` FROM
`city` WHERE `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` =
129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129 OR `ID` = 129
78 Query SELECT `country`.`Code` FROM `country`
78 Query SELECT `city`.`ID` FROM `city` WHERE ( '' = `CountryCode` )
78 Query SELECT `city`.`ID` FROM `city` WHERE ( '' = `CountryCode` )
78 Query SELECT `Code`,`Name`,`Continent`,`Region`,`SurfaceArea`,
`IndepYear`,`Population`,`LifeExpectancy`,`GNP`,`GNPOld`,`LocalName`,
`GovernmentForm`,`HeadOfState`,`Capital`,`Code2` FROM `country` WHERE
`Code` = 'ABW'
78 Query SELECT `city`.`ID` FROM `city` WHERE ( 'ABW' = `CountryCode` )
78 Query SELECT `ID`,`Name`,`CountryCode`,`District`,`Population` FROM
`city` WHERE `ID` = 129
**************End Log***************
Specific questions:
1) Why ask for a full table scans even if it already has the keys it needs?
Indeed, why ask for it multiple times?
2) Putting in TOP values does not work. Why?
3) Putting in WHERE values does seems to help in limiting the recordset, but
Jet still will try to retrieve the whole recordset. Why can't Jet just fetch
the first few rows?
4) Can I improve the behavior somehow?
TIA.