python - MySQL - Match two tables contains HUGE DATA and find the similar data -


i have 2 tables in sql. table 1 contains many data, table 2 contains huge data.

here's code implement using python

import mysqldb  db = mysqldb.connect(host = "localhost", user = "root", passwd="", db="fak") cursor = db.cursor()  #execute sql statement: cursor.execute("select invention_title auip_wipo_sample invention_title in (select invention_title us_pat_2005_to_2012)")  #get result set tuple: result = cursor.fetchall()  #iterate through results , print: record in result:     print record print "finish."  #finish dealing database , close db.commit() db.close() 

however, takes long. have run python script 1 hour, , still doesn't give me results yet.

please me.

do have index on invention_title in both tables? if not, create it:

alter table auip_wipo_sample add key (`invention_title`); alter table us_pat_2005_to_2012 add key (`invention_title`); 

then combine query 1 don't use subqueries:

select invention_title auip_wipo_sample  inner join us_pat_2005_to_2012 on auip_wipo_sample.invention_title = us_pat_2005_to_2012.invention_title 

and let me know results.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -