February 20, 2021 at 11:18 pm
I work on SQL server 2012 I need to search on table partswithcompany that
have 40 million rows .
when make select SearchParts, CompanyId from partswithcompany where
CompanyId=1234 and SearchParts='A5ghf7598fdmlcpghjk'
it is very slow to re
but it take too much long time when make select data from table
or when using where condition is also very slow
so i think more then i get idea to use hash byte column so
How to do that please ?
if you have any good idea to enhance performance i can accept it
create table #partswithcompany
(
SearchParts nvarchar(200),
CompanyId int
)
insert into #partswithcompany (SearchParts,CompanyId)
values
('A5ghf7598fdmlcpghjk',1234),
('AKLJGSA7598fdmlcpghjk',5870),
('KHJLFFS8fdmlcpghjk',123345),
('A5ghf7598f7GGHYUTYA',3456),
('A5ghfJKKJGHHGghjk',9081818)
February 21, 2021 at 1:16 pm
where CompanyId=1234 and SearchParts='A5ghf7598fdmlcpghjk'
Have you got an index on SearchParts, CompanyId (with the Keys in THAT order provided that CompanyID has many rows and SearchParts is reasonably unique)? If the combination of SearchParts and CompanyId IS Unique then be sure to create a UNQIUE Index.
If
CompanyId=1234 and SearchParts='A5ghf7598fdmlcpghjk'
is unique then, with that index, retrieval will be "instant"
February 23, 2021 at 12:37 pm
Can you attach the execution plan?
Michael L John
If you assassinate a DBA, would you pull a trigger?
To properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
February 23, 2021 at 4:21 pm
I work on SQL server 2012 I need to search on table partswithcompany that
have 40 million rows .
when make select SearchParts, CompanyId from partswithcompany where CompanyId=1234 and SearchParts='A5ghf7598fdmlcpghjk'
it is very slow to re
but it take too much long time when make select data from table or when using where condition is also very slow
so i think more then i get idea to use hash byte column so How to do that please ?
if you have any good idea to enhance performance i can accept it
create table #partswithcompany
(
SearchParts nvarchar(200),
CompanyId int
)
insert into #partswithcompany (SearchParts,CompanyId)
values
('A5ghf7598fdmlcpghjk',1234),
('AKLJGSA7598fdmlcpghjk',5870),
('KHJLFFS8fdmlcpghjk',123345),
('A5ghf7598f7GGHYUTYA',3456),
('A5ghfJKKJGHHGghjk',9081818)
Dude! You've posted the same question as you did at the following link! How about providing us with the information that I asked for on that previous post? No one is going to be able to help you without that information other than to suggest the right kind of index, which you offered no proof as having.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply