Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing records from a SQL query
Message
 
 
À
21/01/2010 16:22:54
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01445297
Message ID:
01445333
Vues:
17
>>Can you compare the actual execution plans with and without group by to find out what takes that long?
>
>I can only do it without the group as the other one never finishes. Without the group, I do not see anything wrong except for the fact that it tries to use some combo index that someone wanted to insert in the tables recently. Would there be a way to tell SQL Server to avoid using certain indexes on such query?

I just re-read your original question again. You don't need to group by ChildPK as in your example (unless it was a complete mock) you seemed to take the first record per Parent Key, not by Parent and ChildKey combined.

If so, you need to use my suggestion.

As for your question, I think it's possible, but I need a quick research. In the worse case scenario you may want to use optimizer hints.
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform