Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / March 2008

Tip: Looking for answers? Try searching our database.

Performance on query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RichardO - 03 Mar 2008 20:17 GMT
Hi, I have this query that runs for minutes. I have SQL Server experience but
somehow in Access I get confused. Does anyone know how to improve the
performance? Here is the query:

"SELECT Codes.Code as CodeId, '',StringHeader.Reviewed as EnglishString, ''
as TranslatedString,StringHeader.Length as MaxLength,0 as
Status,StringHeader.Description FROM Codes INNER JOIN StringHeader ON
Codes.Id = StringHeader.CodeId where Codes.Id not in (SELECT String.CodeId
FROM Languages INNER JOIN [String] ON Languages.Id = String.LanguageId WHERE
(((Languages.Extension)='FRE'))) and StringHeader.AreaId=5 UNION ALL SELECT
Codes.Code, StringHeader_Sent.Reviewed, StringHeader.Reviewed,
String.Translated,
StringHeader.Length,Switch([StringHeader_Sent.Reviewed]<>[StringHeader.Reviewed],1,True,2),StringHeader.Description
FROM (StringHeader INNER JOIN Codes ON StringHeader.CodeId = Codes.Id) INNER
JOIN (([String] INNER JOIN Languages ON String.LanguageId = Languages.Id)
INNER JOIN StringHeader_Sent ON (String.CodeId = StringHeader_Sent.CodeId)
AND (String.LanguageId = StringHeader_Sent.LanguageId)) ON Codes.Id =
String.CodeId WHERE (((Languages.Extension) = 'FRE') and
(NoTranslationRequired =0)) ORDER BY 6,
1;"
Jerry Whittle - 03 Mar 2008 20:58 GMT
You'll already done the first thing that I would suggest and that would be
UNION ALL.

Is Languages.Extension indexed? It's in the Where clauses so I'd make sure
it's indexed.

What happens when you remove the Order By at the end? If it runs faster, do
you really need it? For example if the query is used for a report, you don't
need it. Rather you need to do the sorting in the report.

Since it is a Union query, how does each half run alone? That might tell you
where the slowdown occurs.

Sometimes converting a "not in" statement to NOT EXISTS can really work
wonders. Often the reverse is also true. That's why if I have either in a
slow query, I try the opposite just to see.  I believe that the following
will work:

WHERE Not Exists (SELECT "X"
 FROM Languages INNER JOIN [String]
  ON Languages.Id = String.LanguageId
 WHERE Languages.Extension='FRE'
 AND StringHeader.AreaId=5
 AND Codes.Id = String.CodeId)
Signature

Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.

> Hi, I have this query that runs for minutes. I have SQL Server experience but
> somehow in Access I get confused. Does anyone know how to improve the
[quoted text clipped - 16 lines]
> (NoTranslationRequired =0)) ORDER BY 6,
> 1;"
RichardO - 03 Mar 2008 22:10 GMT
Thanks the not exists worked.

> You'll already done the first thing that I would suggest and that would be
> UNION ALL.
[quoted text clipped - 41 lines]
> > (NoTranslationRequired =0)) ORDER BY 6,
> > 1;"
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.