SQL massive performance difference using SELECT TOP x even when x is much higher than selected rows
问题 I'm selecting some rows from a table valued function but have found an inexplicable massive performance difference by putting SELECT TOP in the query. SELECT col1, col2, col3 etc FROM dbo.some_table_function WHERE col1 = @parameter --ORDER BY col1 is taking upwards of 5 or 6 mins to complete. However SELECT TOP 6000 col1, col2, col3 etc FROM dbo.some_table_function WHERE col1 = @parameter --ORDER BY col1 completes in about 4 or 5 seconds. This wouldn't surprise me if the returned set of data