Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Server puzzle
Message
 
 
À
12/06/2011 01:08:24
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01514149
Message ID:
01514164
Vues:
46
>Interesting, the queries are almost identical, but the first takes 71% in the execution plan...
>
>Not sure I understand what you mean by the 71%.
>
>Actually they're somewhat different. (They both certainly work).
>
>Yours was using the OVER statement, which winds up creating a table spool. If you look at the IO statistics, yours has the extra worktable, though both our subsequent # of reads for the 2 tables are the same.
>
>
>Actually, a subquery isn't necessary, this could have been done with a simple JOIN - I used one simply to materialize the line item ratio as a column and then use it to multiply to the freight, as opposed to repeating the same expression twice.

I used OVER clause to add an extra checking column (which you don't have) to verify sum of allocated freight per order. If we remove this column, it will work similar way.
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