New answers tagged

1

Grouping is best done with a sorted input, so we really want to maintain ordered reading from the index. This means that inequality columns cannot be used, as this will mess up the ordering. Equality columns should still come first. Breaking down your current query, we can try and estimate which columns would be most useful: WHERE varcharColumn <> '' --...


2

Typically the WHERE clause is processed before the GROUP BY, so think about it in terms of which will have the most effect. If you've got 1,000,000 rows in your table and your WHERE clause will filter most of them out, then index for the WHERE clause (first), and specifically on the columns that will be most effective at filtering out more rows. If the WHERE ...


1

Below is my table definition Nope - "below" are 2 queries you wrote. Don't make things worse by mis-using terminology. This seems relatively straightforward but that is a rather significant guess based solely on column names. A simple join would be: select ... from dbo.TS_Station as stn inner join dbo.[Checkpoint Movement] as mv on stn.[...


Top 50 recent answers are included