0

I have an internal web page that connects to an SQL2000 database, pulls the data and then displays it on a table. The SQL query takes on average 3 seconds to get the full results (in this instance 59 rows).

select Call_Ref, per_data7, dbo.dateonly(Scheduled_Date_Time) as sched_date, Call_Status_Description, Add1, Add2, Post_Code, contract_short_name, Call_Type_Description, LUCFC_Description, sched_colour_code
from Calls with (nolock)
    inner join Clients with (nolock) on Link_to_Client=Client_Ref
    left join Personnel with (nolock) on Last_Allocated_To=Pers_Ref
    left join LU_Call_Types with (nolock) on Call_Type=Call_Type_Code
    left join Personnel_More with (nolock) on Last_Allocated_To=PER_Link_to_Pers_Ref
    left join LU_Call_Fault_codes with (nolock) on call_fault_code_1=LUCFC_Code
    left join LU_Call_Status with (nolock) on Last_Event_Status=Call_Status_Code
    left join call_more on call_ref=callm_link_to_call
    left join contractids on link_to_contract_header=contract_ref
where dbo.dateonly(Scheduled_Date_Time) between '09/09/2013' and '13/09/2013'
    and Call_Type in ('BC','IN')
    and PER_Data7 in ('Team 1','Team 2','Team 3','Team 4','Team 5','Team 6','Team 7','Team 8','Team 9','Team 10','Gas1')
    and Call_Status_Description in ('Allocated','Reported Done','Complete')
or CALLM_Data21 between '19/08/2013' and '23/08/2013'
    and CALLM_Data22 in ('Team 1','Team 2','Team 3','Team 4','Team 5','Team 6','Team 7','Team 8','Team 9','Team 10','Gas1')
    and link_to_contract_header = 'BGAS-1'
    and call_type not in ('BC','IN')
    and call_status_description not in ('Cancelled')
order by per_data7, dbo.dateonly(Scheduled_Date_Time)

I am then displaying those results in a table, using do/while loops and if statements to filter the results into where they should be displayed in the table - the problem is that each of those takes an additional 3 seconds to display - thus the complete web page takes around 3 and half minutes to fully load (i had to extend the timeout to allow to fully load).

I need to get this down to a usable amount of time.

The webserver is Windows IIS and the web page is basic html, classic-asp with some VB. It server also has PHP installed, but i am not sure which version.

I have attached the files in a ZIP for anyone to look at.

https://www.dropbox.com/s/qbfp0cswo403e4u/files.zip

So, guys.... what can I do to get this page to load in a timescale that makes it actually usable?

A viewable version of the page is here http://195.171.121.111/week0909-test.asp which I will leave there for a day or so.

4

1 回答 1

2

The user defined function function in the where and order by clause is probably causing the slow-down for SQL.

You should be able to pull the query data once, and then build up in memory hashes of the Teams and Dates. Another hash should contain lists of the entries for a cross hash between the team and dates, then you can just iterate over the data set once instead of (team-names.count * dates.count) times.

于 2013-09-12T14:39:58.403 回答