从表中获取大量数据时,我遇到了问题。
我有一个数据库表TblJobs
,在此表中,某些列包含大量数据(此列中大约 60,000 个字符)。
我的桌子:
TblJobs
JobId JobTitle JobDescription
----------------------------------------------------------------
1 Job1 TextTextTextTextTextTextTextTextTextTextTextText... (approx 40,000 characters without any space in job description)
2 Job2 HelloHelloHelloHelloHelloHelloHelloHelloHelloHell..(approx 60,000 characters without any space in job description)
3 Job3 DemoDemoDemoDemoDemoDemoDemoDemoDemoDemoDemoDemo...(approx 60,000 characters without any space in job description)
4 Job4 TestingTestingTestingTestingTestingTestingTesti....(approx 50,000 characters without any space in job description)
表结构为:
JobId - Int
JobTitle - VarChar(500)
JobDescription - VarChar(MAX)
现在我的问题是,当我执行查询以从中选择所有列时,TblJobs
执行时间太长(大约 30 秒)。使用这个 -
Select * from TblJobs
或者
Select JobId, JobTitle, JobDescription from TblJobs
当将一些数据修改到表的列时,我很惊讶JobDescription
,这个查询只在 3-5 秒内执行。
在修改中 - 我在列数据之间提供了一些空格JobDescription
。
例如,您可以看到下表,在此我只在jobDescription
列之间包含一些空格(我没有更改数据类型或数据量):
JobId JobTitle JobDescription
------------------------------------------------------------------------
1 Job1 Text TextTextText**<space>**TextTextTextText**<space>**TextTextTextText... (approx 40,000 characters with some space in job description)
2 Job2 HelloHello**<space>**HelloHelloHelloHello**<space>**HelloHelloHelloHell..(approx 60,000 characters with some space in job description)
3 Job3 DemoDemoDemoDemo**<space>**DemoDemoDemoDemoDemo**<space>**DemoDemoDemo...(approx 60,000 characters with some space in job description)
4 Job4 TestingTesting**<space>**TestingTestingTesting**<space>**TestingTesti....(approx 50,000 characters with some space in job description)
jobdescription
所以我的问题是,为什么在没有空间的情况下选择查询需要很长时间才能执行?我认为,在我的情况下,时间问题与数据量无关。