问题标签 [non-clustered-index]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
463 浏览

sql-server-2008-r2 - 在 SQL Server 2008 R2 的非聚集索引中,索引是指向单行还是一组行?

我试图了解非聚集索引如何在表中查找数据。我认为,非聚集索引在对索引列值进行查找时只是指向一个数据页或一组数据行,而不是指向单个行。也就是说,在使用非聚集索引时,我们仍然需要扫描一个数据页来获取我们正在查找的具体数据行。这是真的?

0 投票
1 回答
656 浏览

sql-server - Can Clustered index change dynamic SQL statement behavior and return different results?

Possible Duplicate:
ORDER BY suddenly conflicting with VARCHAR concatenation in TSQL

recently, I found create clustered index in one table and this clustered index changed the results of a dynamic SQL statement. When the table have clustered index, the statement only returned the last filed result. drop the clustered index from the table or delete the 'ORDER BY fieldnumber', will return the full result (15 fields). The change in behavior was caused by the clustered index in conjunction with the replace calls, as well as the order by, and the declaration of k being 1000 vs max in the sample statement.

Can the Clustered index change dynamic SQL statement behavior and return different results or something else I don't know? Any comments are welcome!

--Create the test table

-- insert test data

-- test script

-- create one clustered index to test the above script

-- test script which with nvarchar(1000)to test the behavior change with clustered index

-- test script which with nvarchar(max)to test the behavior no change under nvarchar (max) combine with clustered index

--drop the clustered index

-- then create nonclustered index

-- test script which with nvarchar(100)to test the behavior no change under nvarchar (100) combine with NONclustered index

0 投票
1 回答
627 浏览

sql-server-2008 - 使用 nhibernate 映射文件创建带有“包含”列的封面索引

我需要创建一个包含 INCLUDE 列的非聚集索引(参见<create>下面的标签)。这是映射文件:

我遇到的问题是根本没有创建索引。似乎什么都没有发生。这是我第一次使用<database-object>,所以我可能在这里做错了什么。

我猜 INCLUDE 是特定于 Sql Server 的,这就是方言范围存在的原因。我知道如何创建单列和多列索引,但这不是我想要的。我想要在查询的 INCLUDE 子句的用户表部分中的邮政编码和所有其他列上的单列索引。有没有办法使用映射文件或其他方式创建这种类型的索引?

这可能是一个很长的镜头,但最好不必指定每一列,而是在查询的 INCLUDE 部分中指定索引的列...而不是让 nhibernate 将任何新列添加到作为属性添加的索引中到映射文件。

0 投票
3 回答
8762 浏览

sql-server - SQL Server 为一列创建多个非聚集索引与在一个索引中创建多个列

假设我有下表

  • UserID(身份)PK
  • UserName- 唯一非空
  • UserEmail- 唯一非空

推荐什么以获得最佳性能?

  • UserName为和UserEmail单独创建非聚集索引

或者

  • 只有一个包括两列

请分享你的想法,为什么一个比另一个更可取。

0 投票
1 回答
807 浏览

sql-server - 为什么主键不是聚集索引而另一个索引是聚集的?

我今天正在查看我们的 SQL Server 数据库的索引,并注意到一个相对较小(非常旧)的表(3250 行),其中有一列类型为 varbinary(max) 的图像数据。

主键是一个非聚集索引,并且有另一个索引(在用户 ID 上并被删除)是聚集的。

同样,这是一张非常古老的桌子,当这张桌子被创建时,周围已经没有人了。

那么,有任何理由以这种方式设置它吗?我应该改变它吗?如果我应该这样做,有什么我应该注意的吗?

0 投票
1 回答
7277 浏览

database - 创建 db2 非聚集索引

您能告诉我如何在 DB2 中创建非聚集索引吗?我找不到任何命令。我想在三列上创建一个索引。我试过:

它给我的错误是:

此外,创建非聚集索引命令不适用于 db2。

任何帮助将不胜感激。

谢谢你。

0 投票
2 回答
2018 浏览

sql - 在 sql server 中使用 ROW_NUMBER 时索引不起作用

我已经使用 Row_Number() 在我的存储过程中实现分页。分页工作正常。但问题是,在实现 Row_Number() 之后,索引不起作用,即使我按部分顺序使用主键列,也会发生聚集索引 SCAN。以下是示例查询:

如果我尝试只执行内部查询:

它不使用任何索引。AdID 是主键,还有另一个非聚集索引涵盖所有 where 子句。但是会发生索引扫描。如果我从内部查询中删除 Row_Number() 并检查其执行计划,所有索引都可以正常工作,但 StateID 和 CityID 在非聚集索引中时再次显示为“谓词”。

请给我一些指导来解决我的两个问题。

0 投票
0 回答
179 浏览

mysql - 具有聚集索引或堆表的表?

如果我有X经常更新(INSERT并且DELETE唯一)的表(堆表),以及Y永远不会超过 2000 行的表怎么办。TableX有一个外键列,引用了 table 的唯一索引,Y关系类型是一对多。但是,每个唯一索引最多只能有 10 个外键,这意味着该表X永远不能超过 20000 行。基本上,表X可以随时有 0-20000 之间的任意数量的行。说得通?

那么堆表在那里好还是我应该在那里添加一个聚集索引?或者也许有人有更好的解决方案?

0 投票
1 回答
894 浏览

sql-server - SQL Server - 从主键中删除集群超时

我有一个大表,目前在 sql server 2012 中有 2500000 行。主键被列为Create as clustered: Yes并且由于主键是一个uniqueidentifier我想将它更改为非集群的初学者(然后在某个时间在未来,改为聚集在日期列上)。

问题是这超时了。禁用索引的集群怎么会很慢?除了将此操作的超时时间增加到 24 小时之外,我能做些什么来加快速度并在超时之前完成?

0 投票
1 回答
3394 浏览

sql - 连接时的非聚集索引

我一直想知道在连接上使用非聚集索引是否会提高性能?喜欢

在上面的连接中,当我在 FaceListID 上有非聚集索引时,我可以获得性能优势,因为它的独特组合并返回明确的结果

任何链接或建议表示赞赏