<i id='fffzQ'><tr id='fffzQ'><dt id='fffzQ'><q id='fffzQ'><span id='fffzQ'><b id='fffzQ'><form id='fffzQ'><ins id='fffzQ'></ins><ul id='fffzQ'></ul><sub id='fffzQ'></sub></form><legend id='fffzQ'></legend><bdo id='fffzQ'><pre id='fffzQ'><center id='fffzQ'></center></pre></bdo></b><th id='fffzQ'></th></span></q></dt></tr></i><div id='fffzQ'><tfoot id='fffzQ'></tfoot><dl id='fffzQ'><fieldset id='fffzQ'></fieldset></dl></div>

    <small id='fffzQ'></small><noframes id='fffzQ'>

  1. <legend id='fffzQ'><style id='fffzQ'><dir id='fffzQ'><q id='fffzQ'></q></dir></style></legend>
  2. <tfoot id='fffzQ'></tfoot>

        <bdo id='fffzQ'></bdo><ul id='fffzQ'></ul>

    1. 选择“where子句"评价顺序

      Select quot;where clausequot; evaluation order(选择“where子句评价顺序)
      • <i id='7dcAC'><tr id='7dcAC'><dt id='7dcAC'><q id='7dcAC'><span id='7dcAC'><b id='7dcAC'><form id='7dcAC'><ins id='7dcAC'></ins><ul id='7dcAC'></ul><sub id='7dcAC'></sub></form><legend id='7dcAC'></legend><bdo id='7dcAC'><pre id='7dcAC'><center id='7dcAC'></center></pre></bdo></b><th id='7dcAC'></th></span></q></dt></tr></i><div id='7dcAC'><tfoot id='7dcAC'></tfoot><dl id='7dcAC'><fieldset id='7dcAC'></fieldset></dl></div>
          <bdo id='7dcAC'></bdo><ul id='7dcAC'></ul>

              <small id='7dcAC'></small><noframes id='7dcAC'>

            1. <tfoot id='7dcAC'></tfoot>
                <tbody id='7dcAC'></tbody>
              <legend id='7dcAC'><style id='7dcAC'><dir id='7dcAC'><q id='7dcAC'></q></dir></style></legend>

                本文介绍了选择“where子句"评价顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在 Sql Server 2005 中,当我有多个参数时,是否可以保证评估顺序总是从左到右?

                In Sql Server 2005 when I have multiple parameters do I have the guarantee that the evaluation order will always be from left to right?

                举个例子:

                从表中选择一个,其中 c=1 和 d=2

                在这个查询中,如果c=1"条件失败,d=2"条件将永远不会被评估?

                In this query if the "c=1" condition fails the "d=2" condition will never be evaluated?

                PS-"c" 是整数索引列,d 是大 varchar 且不可索引的列,需要全表扫描

                PS- "c" is an integer indexed column, d is a large varchar and non indexable column that requires a full table scan

                update 我试图避免执行两个查询或条件语句,我只需要这样的东西:如果c 条件"失败,则有一种方法可以避免执行繁重的d 条件",因为它是在我的情况下不需要.

                update I was trying to avoid performing two queries or conditional statements, I just need something like: if "c condition" fails there's a way to avoid performing the heavy "d condition", since it's not needed in my case.

                推荐答案

                不保证评估顺序.优化器将尝试使用可用信息找到执行查询的最有效方式.

                There are no guarantees for evaluation order. The optimizer will try to find the most efficient way to execute the query, using available information.

                在您的情况下,由于 c 已编入索引而 d 未编入索引,优化器应查看索引以查找与 c 上的谓词匹配的所有行,然后从表数据中检索这些行以评估 d 上的谓词.

                In your case, since c is indexed and d isn't, the optimizer should look into the index to find all rows that match the predicate on c, then retrieve those rows from the table data to evaluate the predicate on d.

                但是,如果它确定 c 上的索引不是很有选择性(尽管不是在您的示例中,性别列很少被有用地索引),它可能决定无论如何都要进行表扫描.

                However, if it determines that the index on c isn't very selective (although not in your example, a gender column is rarely usefully indexed), it may decide to do the table scan anyway.

                要确定执行顺序,您应该获得查询的解释计划.但是,请注意,该计划可能会根据优化器目前认为的最佳查询而改变.

                To determine execution order, you should get an explain plan for your query. However, realize that that plan may change depending on what the optimizer thinks is the best query right now.

                这篇关于选择“where子句"评价顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Building a comma separated list?(建立一个逗号分隔的列表?)
                Errors in SQL Server while importing CSV file despite varchar(MAX) being used for each column(尽管每列都使用了 varchar(MAX),但在导入 CSV 文件时 SQL Server 中出现错误)
                How can I import an Excel file into SQL Server?(如何将 Excel 文件导入 SQL Server?)
                Export table to file with column headers (column names) using the bcp utility and SQL Server 2008(使用 bcp 实用程序和 SQL Server 2008 将表导出到带有列标题(列名称)的文件)
                Concat field value to string in SQL Server(将字段值连接到 SQL Server 中的字符串)
                SQL Server Bulk insert of CSV file with inconsistent quotes(SQL Server 批量插入带有不一致引号的 CSV 文件)

                        <tbody id='d6VH4'></tbody>

                    1. <i id='d6VH4'><tr id='d6VH4'><dt id='d6VH4'><q id='d6VH4'><span id='d6VH4'><b id='d6VH4'><form id='d6VH4'><ins id='d6VH4'></ins><ul id='d6VH4'></ul><sub id='d6VH4'></sub></form><legend id='d6VH4'></legend><bdo id='d6VH4'><pre id='d6VH4'><center id='d6VH4'></center></pre></bdo></b><th id='d6VH4'></th></span></q></dt></tr></i><div id='d6VH4'><tfoot id='d6VH4'></tfoot><dl id='d6VH4'><fieldset id='d6VH4'></fieldset></dl></div>

                      <tfoot id='d6VH4'></tfoot>
                        <legend id='d6VH4'><style id='d6VH4'><dir id='d6VH4'><q id='d6VH4'></q></dir></style></legend>
                          <bdo id='d6VH4'></bdo><ul id='d6VH4'></ul>
                        • <small id='d6VH4'></small><noframes id='d6VH4'>