Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 for minimizing the time complexity

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-26 : 08:23:02
ashish writes "1.IS THERE ANY FUNCTION IN SQL WHICH RETURNS THE PERCENTAGE OF MATCHING OCCUR AMONG TWO DIFFERENT WORDS.

2. THERE ARE TWO TABLES WITH 10,000 RECORDS IN EACH TABLE FOR THE MATCHING AMONG THESE TWO WE USE CURSOR ON ONE TABLE AND PICKING THE SECOND TABLES RECORD USING THE IDENTITY COLUMN AND MAKING USE OF DIFFERENCE FUNCTION FOR THE MATCHING OF WORDS. SINCE TABLES CAN BE OF HUGE SIZE THE TIME COMPLEXITY OF DOING SUCH WORK EXCEEEDS, HOW CAN WE REDUCE THE TIME COMPLEXITY?"

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-01-26 : 08:27:52
quote:
HOW CAN WE REDUCE THE TIME COMPLEXITY?
STOP WRITING CODE IN ALL CAPS. IT'S RUDE, ANNOYING, AND SLOWER TO READ, AND IT TAKES THE COMPUTER LONGER TO EXECUTE IT.

Okay, the last part is not true, but the rude, annoying, and slower-to-read part is.

If you want speed, don't use cursors. Pretty simple there. Use a regular JOIN:

SELECT * FROM TableA A INNER JOIN TableB B ON A.col=B.col

If you have to use a user-defined function to determine the equality, something like:

SELECT * FROM TableA A INNER JOIN TableB B ON dbo.UDF(A.col)=dbo.UDF(B.col)
...or...
SELECT * FROM TableA A INNER JOIN TableB B ON dbo.UDF(A.col, B.col)=1

Without seeing your code it's impossible to make further suggestions. Posting your code (queries, table structures, functions and procedures) would help.

There is no built-in function in SQL Server for word matching, but this article may work for you:

http://www.sqlteam.com/item.asp?ItemID=5857
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-26 : 08:28:54
1. NO, maybe you could use soundex() or difference() functions.
2. well cursor is slow. but for anything more constructive we'd need to see what are you working with now.

Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -