Reputation: 6462
My c# application reads file list from web service 1 and insert full file names to table1, then reads list from the second web service and insert them to table2.
These tables have identical structure, like this:
create table table1(id int, filename text)
The task is: to compare these tables and select the common filenames, and the distinct.
If these table are large the compare is the long executing process.
How to improve it? How to add hash field to these tables and how to calculate it automatically? Other way?
Upvotes: 1
Views: 246
Reputation: 520978
The following join query should do the trick:
SELECT DISTINCT t1.filename
FROM table1 t1
INNER JOIN table2 t2
ON t1.filename = t2.filename
This query could benefit from an index on the filename
columns in both tables.
Upvotes: 2