performance - Having a lot of SQL query conditions -
i updating remote mysql database comparing row row local mssql one. idea update in 3 steps:
1: select id's local , execute following query on remote:
delete remote_database.table id not in ( list of local_database.table id's linked or condition )
2: select id's local_database.table not exist on remote , insert
3: update rows have both tables.
my question regarding first step: have 50000+ products. working in c# , join id's in string wondering can query 50000 id's linked or condition executed? wrong approach?
so have done before. long time ago though might miss step hope idea.
- setup linked server on mssql database mysql database. see linked mysql server article
select
table want linked server temp table on mssql sql.select * #temp linkedserver.tablename
better create proper temp table , index columns joining on i.e.create table #test ( id int primary key not null ) insert #test select * linkedserver.tablename
do left/right join find new id on local machine , insert them remote server via linked server. see link more information on how use left/right joins new records when comparing 2 tables using left join find new rows
update remote server update statement , join in it. using inner join update remote server values in temp table.
now there might errors run syntax post them here , can try , resolve them you. have used technique synchronize between mysql , mssql servers , works pretty well. sets based , not rbar based fast well.
Comments
Post a Comment