B
bdtmike
I have a query that JET doesn't optimize as wewll as it should. Does
anybody have any ideas how to force JET to handle this situation
better?
I have an Access application that uses linked tables on a SQL Server
2000 database. These are large tables (400,000+ rows).
I have a query screen I've designed for my users. They can enter
criteria for a number of different fields. I construct an SQL statement
and it results in a simple one-table SELECT statement with WHERE
criteria. Here's the rub: Some of the criteria fields result in an SQL
statement with a WHERE clause that involves Access expressions that
must be processed locally. This, itself, isn't a big deal. Jet
correctly passes the criteria that can be processed at the server and
the local processing is evaluated against this smaller result set.
However, there is one criteria they may specify that requires a lookup
into a 2nd table. I have implemented this as an IN clause and a
subquery. When this occurs, JET doesn't send this to SQL server along
with the other criteria that can be processed there. Instead, it
evaluates this subquery for each and every record that is processed
locally. On a 400,000 row table, this makes for one slow-ass query!
I've tried building a querydef that executes the subquery and building
another query that hits on this, but JET "Optimizes" this in the same
slow way. Any ideas on how to get around this behavior?
anybody have any ideas how to force JET to handle this situation
better?
I have an Access application that uses linked tables on a SQL Server
2000 database. These are large tables (400,000+ rows).
I have a query screen I've designed for my users. They can enter
criteria for a number of different fields. I construct an SQL statement
and it results in a simple one-table SELECT statement with WHERE
criteria. Here's the rub: Some of the criteria fields result in an SQL
statement with a WHERE clause that involves Access expressions that
must be processed locally. This, itself, isn't a big deal. Jet
correctly passes the criteria that can be processed at the server and
the local processing is evaluated against this smaller result set.
However, there is one criteria they may specify that requires a lookup
into a 2nd table. I have implemented this as an IN clause and a
subquery. When this occurs, JET doesn't send this to SQL server along
with the other criteria that can be processed there. Instead, it
evaluates this subquery for each and every record that is processed
locally. On a 400,000 row table, this makes for one slow-ass query!
I've tried building a querydef that executes the subquery and building
another query that hits on this, but JET "Optimizes" this in the same
slow way. Any ideas on how to get around this behavior?