I have a query that uses several LEFT JOINs to gather all its data from various lookup tables. However, oneof the criteria fed into that query is performing extremely poorly.
Setup:
[Products] with ProductID as PK, has 50000 records
[ProdSuppls] with ProductID+SupplierID as PK, has 80000 records
[Suppliers] with SupplierID as PK, has 1000 records
The query:
SELECT [Products].ProductID FROM [Products] LEFT JOIN ([ProdSuppls] LEFT JOIN [Suppliers] ON [ProdSuppls].SupplierID = [Suppliers].SupplierID) ON [Products].ProductID = [ProdSuppls].ProductID WHERE [Suppliers].Name LIKE "[aàáâãäåAÀÁÂÃÄÅ]m[aàáâãäåAÀÁÂÃÄÅ]d[eèéêëÈÉÊË][uùúûüUÙÚÛÜ]s*"
When I run this query it takes about 3 secs. to return 7 records with "Amadéus" as the Supplier name.
Obviously I thought the query criteria was the culprit. However, when I run the query SELECT * FROM [Suppliers] WHERE Name LIKE "[aàáâãäåAÀÁÂÃÄÅ]m[aàáâãäåAÀÁÂÃÄÅ]d[eèéêëÈÉÊË][uùúûüUÙÚÛÜ]s*"
directly against the [Suppliers] table, a single record ("Amadéus") is returned instantaneously.
It looks to me like Access is not properly optimizing the execution plan for the query, but I have no way of telling.
Can anyone shed some light on this and maybe recommend a better way?
Setup:
[Products] with ProductID as PK, has 50000 records
[ProdSuppls] with ProductID+SupplierID as PK, has 80000 records
[Suppliers] with SupplierID as PK, has 1000 records
The query:
SELECT [Products].ProductID FROM [Products] LEFT JOIN ([ProdSuppls] LEFT JOIN [Suppliers] ON [ProdSuppls].SupplierID = [Suppliers].SupplierID) ON [Products].ProductID = [ProdSuppls].ProductID WHERE [Suppliers].Name LIKE "[aàáâãäåAÀÁÂÃÄÅ]m[aàáâãäåAÀÁÂÃÄÅ]d[eèéêëÈÉÊË][uùúûüUÙÚÛÜ]s*"
When I run this query it takes about 3 secs. to return 7 records with "Amadéus" as the Supplier name.
Obviously I thought the query criteria was the culprit. However, when I run the query SELECT * FROM [Suppliers] WHERE Name LIKE "[aàáâãäåAÀÁÂÃÄÅ]m[aàáâãäåAÀÁÂÃÄÅ]d[eèéêëÈÉÊË][uùúûüUÙÚÛÜ]s*"
directly against the [Suppliers] table, a single record ("Amadéus") is returned instantaneously.
It looks to me like Access is not properly optimizing the execution plan for the query, but I have no way of telling.
Can anyone shed some light on this and maybe recommend a better way?