Performance issue while doing Sql server full text search with additional conditions.
I am trying to filter the data based on search filters list (table value parameter), which will return all the records for match filters and single record for the filter doesn’t have any record from tables.
Full text search index is already on table “Names” for column “SNAME”.
In Stored procedure, table type parameter “SearchFilter” is used to pass list of name and address info.
Both tables have more than 14 million records, when we execute the procedure with 1000 unique records passed in filters list it took around 7 minutes to return the result (1400 records).
Filter criteria is: contains(name) and streetaddress, city, state, zip exact match.
Is there any alternate to avoid while loop as SQL server “CONTAINS” function required string value or variable?
CREATE TABLE [dbo].[Names]( [ID] [int] IDENTITY(1,1) NOT NULL, [UIN] [varchar](9) NULL, [SNAME] [varchar](500) NULL, CONSTRAINT [PK_Names] PRIMARY KEY CLUSTERED ( [ID] ASC ) CREATE TABLE [dbo].[ADDRESSES]( [UIN] [varchar](9) NULL, [STREET1] [varchar](100) NULL, [STREET2] [varchar](50) NULL, [CITY] [varchar](30) NULL, [STATE] [varchar](2) NULL, [ZIP] [varchar](10) NULL ) ON [PRIMARY] CREATE TYPE [dbo].[SearchFilter] AS TABLE( [UIN] [varchar](40) NULL, [SNAME] [varchar](max) NULL, [StreetAddress] [varchar](max) NULL, [City] [varchar](max) NULL, [State] [varchar](50) NULL, [Zip] [varchar](20) NULL ) -- Stored procedure logic Declare @filterList As [dbo].[SearchFilter] DECLARE @NoOfRows int,@counter int=0 set @NoOfRows = (SELECT count(1) FROM @filterList) DECLARE @result table(UIN varchar(40),NAME varchar(500),StreetAddress varchar(1000), Zipcode varchar(20),State varchar(20),City varchar(1000),IsRecordFound varchar(50)); WHILE(@NoOfRows>@counter) BEGIN DECLARE @SearchName varchar(4000) set @SearchName = (SELECT '"'+SNAME+'"' FROM @filterList ORDER BY SNAME OFFSET @counter ROWS FETCH NEXT 1 ROWS ONLY) --Start: Process to Select Records ;with Filter_CTE as (select SNAME,StreetAddress,City,State,ZipCode from @filterList ORDER BY SNAME OFFSET @counter ROWS FETCH NEXT 1 ROWS ONLY ) insert INTO @result (UIN,NAME,STREETADDRESS,CITY,STATE,ZIPCODE,PHONE,IsRecordFound) select DISTINCT en.UIN,isnull(en.SNAME,Filter_CTE.SNAME),Filter_CTE.StreetAddress,Filter_CTE.ZipCode,Filter_CTE.state,Filter_CTE.City ,iif(en.UIN IS null,'Not Found','Found') AS IsRecordFound FROM dbo.Names en INNER JOIN dbo.ADDRESSES ea ON en.UIN = ea.UIN RIGHT JOIN Filter_CTE ON ea.ZIP = Filter_CTE.Zip AND ea.STATE = Filter_CTE.State AND ea.CITY = Filter_CTE.City AND (isnull(ea.STREET1,'') +' '+isnull(ea.STREET2,'')) = Filter_CTE.StreetAddress AND CONTAINS(en.SNAME,@SearchName) --END set @counter+=1 END SELECT UIN,NAME,STREETADDRESS,CITY,STATE,ZIPCODE,PHONE FROM @result
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!