Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with View
Message
De
11/10/2013 00:01:24
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Problem with View
Versions des environnements
SQL Server:
SQL Server 2008 R2
Application:
Desktop
Divers
Thread ID:
01585239
Message ID:
01585239
Vues:
50
Hi,

I have a defined a complicated view vwSalesResults that returns details from tables on 3 SQL Servers.
I need to use a view rather than a stored procedure because the 3rd Party application that uses the result set does not support calling a stored procedure. It only permits you to select from a table or view.

Using SSMS

1. if I run the query
select * from vwSalesResults
857 records are returned in 8 seconds.

2. if I run the query
select * from vwSalesResults where HeadOfficeCode = 'AAA'
57 records are returned in 8.5 seconds.

3. if I run the query
select * from vwSalesResults where HeadOfficeCode = 'BBB'
12 records are returned in 84 seconds.

If I examine the actual execution plans for case 2 and case 3 they differ. 8 seconds for cases 1 and 2 is acceptable but 84 seconds for case 3 is not.

Any suggestions most gratefully received,

TIA Andy
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform