Do you use TOP for sampling in your queries?

Last updated by Bahjat Alaadel [SSW] 4 months ago.See history

Top is an efficient way of identifying what a tables structure and data look like.


Video: Use TOP for sampling for SQL performance | Bryden Oliver (3 min)

Retrieving all the data in a table is a common pattern especially when someone is looking into a production incident. If the table in question is a large table, grabbing all the rows back may make the problem worse.

SELECT * FROM Users

Using TOP to reduce the number of rows being returned makes this a much less expensive operation.

SELECT TOP 20 FROM Users

TOP works with filtering and joining, so you can use it to get a sample of only the rows you are interested in.


We open source.Loving SSW Rules? Star us on GitHub. Star
Stand by... we're migrating this site to TinaCMS