I'm having trouble with the following stored procedure and others like it, running to slow. It is especially slow the first time into the database.
Each of the tables contains about 1,200,000 rows.
SELECT c.client_lname,
c.client_fname,
c.client_mname,
c.client_DOB,
c.client_soc_sec_num,
c.client_telephone_num,
c.client_nmidno,
c.client_sex_code,
c.client_prefix,
c.client_suffix,
c.client_type,
c.client_name_hna_format,
l.clientloc_nmidno,
l.clientloc_address_1,
l.clientloc_address_2,
l.clientloc_address_3,
l.clientloc_address_4,
l.clientloc_address_5,
l.clientloc_city,
l.clientloc_state,
l.clientloc_zip
FROM client c inner join client_location l
ON c.client_nmidno = l.clientloc_nmidno
WHERE (clientloc_state like @state)
Without and index on clientloc_state it runs about 3 minutes.
With an index on clientloc_state it runs about 1.45 minutes.
Somewhat faster but not the response time I'm looking for.
Is there a way to make this run faster? Why does response time improve to about 16 seconds the second time running the stored procedure?
Thanks
Each of the tables contains about 1,200,000 rows.
SELECT c.client_lname,
c.client_fname,
c.client_mname,
c.client_DOB,
c.client_soc_sec_num,
c.client_telephone_num,
c.client_nmidno,
c.client_sex_code,
c.client_prefix,
c.client_suffix,
c.client_type,
c.client_name_hna_format,
l.clientloc_nmidno,
l.clientloc_address_1,
l.clientloc_address_2,
l.clientloc_address_3,
l.clientloc_address_4,
l.clientloc_address_5,
l.clientloc_city,
l.clientloc_state,
l.clientloc_zip
FROM client c inner join client_location l
ON c.client_nmidno = l.clientloc_nmidno
WHERE (clientloc_state like @state)
Without and index on clientloc_state it runs about 3 minutes.
With an index on clientloc_state it runs about 1.45 minutes.
Somewhat faster but not the response time I'm looking for.
Is there a way to make this run faster? Why does response time improve to about 16 seconds the second time running the stored procedure?
Thanks