简体   繁体   中英

Azure SQL Query Performance Issue

I'm running a query against an Azure SQL DB...

select Id
from Table1
  WHERE ([Table1].[CustomFieldString2] IS NULL) AND
        (N'New' = [Table1].[CustomFieldString7]) AND (0 = [Table1].[Deleted])

This query runs fast roughly 300ms...

As soon as I add another column to my select (bool) as in

Select Id, IsActive

my query is super slow (minutes)

This doesn't make any sense...

Was wondering if anyone knew what this could be

In Summary, when you add columns which are not part of index to the select then SQL can't choose the same execution plan.

If SQL estimates there are fewer rows, then it will opt to use nested lookups in the execution plan. This can take more time, if estimates are wrong.

If there are more rows or key lookup cost crosses some threshold, SQL may then decide that a scan of the table is likely to be more efficient.

Try adding isactive to the included column list, if the query performance is not acceptable.

You query constructure is important of course but Azure is naturally slow. Is is using cloud systems so it is not so fast (I supposed using free version.) ı have not seen anyone pleasure about azure velocity. (in low prices)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM