Query question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Van T. Dinh (VanThien.Dinh_at_discussions.microsoft.com)
Date: 06/10/04


Date: Wed, 9 Jun 2004 20:55:44 -0700

They look like SQLServer syntax to me, perhaps from
SQLServer Back-End.

If this is the case, you may like to check the Query
(execution) Plan in SQLServer Query Analyser and see which
section in the 2nd Query takes most time and see if you
can re-structure the SQL.

It is likely that in the first Query, indices are used
while in the 2nd Query, indices are not being used and the
hash Tables (?) are needed.

HTH
Van T. Dinh
MVP (Access)

 
>-----Original Message-----
>My question is why does the first query below take about
>5 seconds to run, where the second query takes about 5
>minutes to run? The only difference is the first has the
>criteria enter in the query and the second is using the
>table shown below.
>
>SELECT dbo_sh_sales.store, dbo_sh_sales.upc,
>dbo_sh_sales.pricetype, dbo_sh_sales.quantity,
>dbo_sh_time.ActualDate
>FROM dbo_sh_time INNER JOIN dbo_sh_sales ON
>dbo_sh_time.DateKey = dbo_sh_sales.date
>WHERE (((dbo_sh_sales.store)=4) AND ((dbo_sh_sales.upc)
>=1714) AND ((dbo_sh_sales.pricetype)=8 Or
>(dbo_sh_sales.pricetype)=9 Or (dbo_sh_sales.pricetype)=10
>Or (dbo_sh_sales.pricetype)=11) AND
>((dbo_sh_time.ActualDate)<Date()));
>
>
>
>
>SELECT dbo_sh_sales.store, dbo_sh_sales.upc,
>dbo_sh_sales.pricetype, dbo_sh_sales.quantity,
>dbo_sh_time.ActualDate
>FROM DistinctStoreUPC, dbo_sh_time INNER JOIN
>dbo_sh_sales ON dbo_sh_time.DateKey = dbo_sh_sales.date
>WHERE (((dbo_sh_sales.store)=[DistinctStoreUPC]![STORE])
>AND ((dbo_sh_sales.upc)=[DistinctStoreUPC]![UPC]) AND
>((dbo_sh_sales.pricetype)=8 Or (dbo_sh_sales.pricetype)=9
>Or (dbo_sh_sales.pricetype)=10 Or (dbo_sh_sales.pricetype)
>=11) AND ((dbo_sh_time.ActualDate)<Date()));
>
>
>
>
>DistinctStoreUPC
>STORE UPC
>4 1714
>
>.
>



Relevant Pages

  • Re: IIF Statement to calculate aging buckets
    ... If Access says it's too complex, Access can't understand it -- incorrect may ... Now create a second query, ... all the fields from the first query, then add your original IIFstatement. ...
    (microsoft.public.access.queries)
  • Re: how do i count consecutive records with a field value >=1
    ... The first query consider for each record how many records in table ... The second query keep only the ranks where bal <0. ... but i don't have a clue how your sql got the results i needed. ...
    (microsoft.public.access.queries)
  • Re: IIF Statement to calculate aging buckets
    ... >> parameter needs to be defined as Date Type in the query. ... >> Jeff Boyce wrote: ... >>> Now create a second query, ... >>> all the fields from the first query, ...
    (microsoft.public.access.queries)
  • Re: IIF Statement to calculate aging buckets
    ... > parameter needs to be defined as Date Type in the query. ... > Jeff Boyce wrote: ... >> Now create a second query, ... >> all the fields from the first query, ...
    (microsoft.public.access.queries)
  • Re: Microsoft Access Expression Problem
    ... and then, juggle 2 instances ... Then I figured that i just needed to run the second query ... "Moving_Minimum" because it references the first query and probably ...
    (microsoft.public.access.queries)