当行数变大时,无法从SQL查询获得所需的结果 [英] Desired result is not getting from SQL query when the number of rows become large

查看:61
本文介绍了当行数变大时,无法从SQL查询获得所需的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的应用程序使用SQL Server 2005 Express版.对于行数较少的查询,我得到了正确的结果.但是行数变为12000或更多,结果的顺序不理想.

(我的机器的配置是Intel Core 2 duo处理器,2 GB RAM,Windows Xp Professional Service Pack2.)


这是SQL Server 2005 Express版本还是我的查询问题?

请帮助我...预先感谢...

I am using SQL Server 2005 Express edition for my Application. I gets the correct result for the queries with smaller number of rows. But the number of rows become 12000 or greater, result is not in the desired order.

(My machine''s configuration is Intel core 2 duo processor, 2 GB RAM, Windows Xp Professional service pack 2.)


Is this the problem of SQL Server 2005 Express edition,or my query?

Please help me... Thanks in advance...

推荐答案

很可能是您的查询,您需要为表建立索引.
Most likely it is your query and you need to build indexes for your tables.


亲爱的阿伦,

我认为这需要索引.

使用此链接创建索引

使用SQL Server 2005定义索引 [
Dear Arun,

I think it requires indexing.

use this link to create indexes

Defining Indexes with SQL Server 2005[^]

creation of primary key and foreign key relationship in database , will make faster access.

Thanks,


但是行数变为12000或更多,结果的顺序不理想."

如果这是问题的症结所在,那么我猜想查询中包含您希望对结果进行排序的子句,但不是,或者更确切地说_sometimes_对结果进行排序的子句,即"group by"或选择不同的''

再次没有实际看到代码,我只是进行了有根据的猜测,但是如果您希望结果以特定的顺序出现,那么确保此结果的唯一方法就是使用"order by":-)
"But the number of rows become 12000 or greater, result is not in the desired order."

If this is the crux of the problem then I am guessing the query contains a clause you expect to order the result but which isn''t, or rather which _sometimes_ orders the result, i.e. a ''group by'' or a ''select distinct''

Again without actually seeing the code I''m just taking an educated guess but if you are expecting the result to appear in a particular order then the only way to ensure this is to use an ''order by'' :-)


这篇关于当行数变大时,无法从SQL查询获得所需的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆