Ask a Question related to Coldfusion Database Access, Design and Development.
-
cfoster #1
Queries slower with SQL Server than Access
Hoping for better security and performance, I'm moving data from an Access
database to SQL Server. However, our more query-intensive reports in CF are
taking significantly longer to run with SQL Server, not what I expected. For
example, the following query counts how many eligible surveys received a
response of '2' to each of the survey questions. Here's the SQL version:
select SourceID, count1_1 = sum (case when Q1_1=2 then 1 else 0 end), count1_2
= sum (case when Q1_2=2 then 1 else 0 end), count1_3 = sum (case when Q1_3=2
then 1 else 0 end), count1_4 = sum (case when Q1_4=2 then 1 else 0 end),
count1_5 = sum (case when Q1_5=2 then 1 else 0 end), count1_6 = sum (case when
Q1_6=2 then 1 else 0 end), count1_7 = sum (case when Q1_7=2 then 1 else 0 end),
count1_8 = sum (case when Q1_8=2 then 1 else 0 end), count1_9 = sum (case when
Q1_9=2 then 1 else 0 end), count2_1 = sum (case when Q2_1=2 then 1 else 0 end),
count2_2 = sum (case when Q2_2=2 then 1 else 0 end), count2_3 = sum (case when
Q2_3=2 then 1 else 0 end), count2_4 = sum (case when Q2_4=2 then 1 else 0 end),
count2_5 = sum (case when Q2_5=2 then 1 else 0 end), count2_6 = sum (case when
Q2_6=2 then 1 else 0 end), count3_1 = sum (case when Q3_1=2 then 1 else 0 end),
count3_2 = sum (case when Q3_2=2 then 1 else 0 end), count3_3 = sum (case when
Q3_3=2 then 1 else 0 end), count3_4 = sum (case when Q3_4=2 then 1 else 0 end),
count4_1 = sum (case when Q4_1=2 and StudentAge > 2 and StudentAge < 7 then 1
else 0 end), count4_2 = sum (case when Q4_2=2 and StudentAge > 4 and StudentAge
< 9 then 1 else 0 end), count4_3 = sum (case when Q4_3=2 and StudentAge > 13
then 1 else 0 end), count4_4 = sum (case when Q4_4=2 and StudentAge > 13 then 1
else 0 end), count4_5 = sum (case when Q4_5=2 and StudentAge > 13 then 1 else 0
end), count5_1 = sum (case when Q5_1=2 and StudentAge < 5 then 1 else 0 end),
count5_2 = sum (case when Q5_2=2 and StudentAge < 5 then 1 else 0 end),
count5_3 = sum (case when Q5_3=2 and StudentAge < 5 then 1 else 0 end),
count5_4 = sum (case when Q5_4=2 and StudentAge < 5 then 1 else 0 end),
count5_5 = sum (case when Q5_5=2 and StudentAge < 5 then 1 else 0 end),
count5_6 = sum (case when Q5_6=2 and StudentAge < 5 then 1 else 0 end),
count5_7 = sum (case when Q5_7=2 and StudentAge < 5 then 1 else 0 end),
count6_1 = sum (case when Q6_1=2 then 1 else 0 end), count6_2 = sum (case when
Q6_2=2 then 1 else 0 end), count6_3 = sum (case when Q6_3=2 then 1 else 0 end),
count6_4 = sum (case when Q6_4=2 then 1 else 0 end), count6_5 = sum (case when
Q6_5=2 then 1 else 0 end) from tblSurveys where districtID IN
(20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,3 6,38) group by SourceID order
by SourceID CF debugging times this query at 250ms, whereas the Access query
runs in 63ms. And, that's with nearly twice as many surveys recorded in the
Access database. The Access query is essentially the same, using IIF instead of
CASE (e.g. Sum(IIf(Q1_1=2,1,0)) as count1_1). When I run the SQL query in Query
Analyzer, the results come back instantaneously (zero seconds), so the problem
seems to be with ColdFusion's handling of the query. I tried using a stored
procedure instead of a query and ColdFusion took just as long. Any suggestions
for improving performance? Thanks!
cfoster Guest
-
SQL queries when Access is open
My Authorware training piece sends and retrieves data through asp pages that are connected to an Access database. Three asp pages use SQL SELECT,... -
Creating queries in Access (for ASP)
Hi, So far I have been writing ASP and embedding my SQL in the ASP pages. But, I've heard advantages of creating queries inside the database... -
Translate Access queries to ASP
Hi, I'm still confused about my queries, I want to do something is ASP that is easily done in Access. I'll post the Access queries below as a... -
using Access queries using ADOX
Hello, I have the following code in an asp 3.0 page: Dim dbConn As adodb.Connection Dim cat As ADOX.Catalog Dim view As ADOX.view Set dbConn... -
SQL Server 2000 SP3: Why is Table variable slower than temp tables?
Hello, Recently, I am trying to optimize some old stored procedures. In the process, I found out in the online help that a "table variable" is... -
briguyCF151 #2
Re: Queries slower with SQL Server than Access
Maybe run it as either a view or stored procedure. Just taking a guess
briguyCF151 Guest
-
philh #3
Re: Queries slower with SQL Server than Access
Do you have indices on the aggregated and WHERE clause fields? Run the query
in QA with Execution Plan tab turned on and see if there are table scans.
Definitely create an SP so SQL can cache the plan.
philh Guest



Reply With Quote

