Commit ac885b90 authored by Romain Loth's avatar Romain Loth

dbdatapi: extract loop replaced by WHERE..IN (25 x faster)

parent 07eeea46
...@@ -585,8 +585,7 @@ class BipartiteExtractor: ...@@ -585,8 +585,7 @@ class BipartiteExtractor:
# mlog("DEBUG", "MySQL extract scholar_array:", scholar_array) # mlog("DEBUG", "MySQL extract scholar_array:", scholar_array)
# scholar_array = list(scholar_array.keys())[0:3] # scholar_array = list(scholar_array.keys())[0:3]
# TODO loop could be after SELECT
for scholar_id in scholar_array:
sql3=''' sql3='''
SELECT SELECT
scholars_and_orgs.*, scholars_and_orgs.*,
...@@ -627,16 +626,17 @@ class BipartiteExtractor: ...@@ -627,16 +626,17 @@ class BipartiteExtractor:
ON sch_kw.uid = scholars_and_orgs.luid ON sch_kw.uid = scholars_and_orgs.luid
LEFT JOIN keywords LEFT JOIN keywords
ON sch_kw.kwid = keywords.kwid ON sch_kw.kwid = keywords.kwid
WHERE luid = %s WHERE luid IN %s
GROUP BY luid ; GROUP BY luid ;
''' % scholar_id ''' % ('('+','.join(map(str, list(scholar_array.keys())))+')')
# debug # debug
# mlog("DEBUG", "db.extract: sql3="+sql3) mlog("DEBUG", "db.extract: sql3="+sql3)
try: try:
self.cursor.execute(sql3) self.cursor.execute(sql3)
res3=self.cursor.fetchone()
for res3 in self.cursor:
info = {}; info = {};
# semantic short ID # semantic short ID
...@@ -706,7 +706,6 @@ class BipartiteExtractor: ...@@ -706,7 +706,6 @@ class BipartiteExtractor:
mlog("ERROR", "===== /extract ERROR ====") mlog("ERROR", "===== /extract ERROR ====")
# génère le gexf # génère le gexf
# include('gexf_generator.php'); # include('gexf_generator.php');
imsize=80; imsize=80;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment