From 8306d8587faf134282687b9a0ea7fcb9d4ebd18c Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 3 Apr 2014 12:37:52 +1100 Subject: [PATCH] Move the view table/creation to after data collection. It takes longer to create table than a view but the view is slower in use than is a table. make this move in preparation to having an option to create either a view or a table for this information. --- site_ansto/xref.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/site_ansto/xref.py b/site_ansto/xref.py index f8c32c68..0562152d 100755 --- a/site_ansto/xref.py +++ b/site_ansto/xref.py @@ -18,14 +18,6 @@ def setup_database(): curs.execute("CREATE INDEX symidx ON symtab ( name )") curs.execute("CREATE VIEW defs AS SELECT DISTINCT s.name sym, s.obj_id mod FROM symtab s WHERE s.usage != 'U'"); curs.execute("CREATE VIEW refs AS SELECT DISTINCT s.name sym, s.obj_id mod FROM symtab s WHERE s.usage = 'U'"); - curs.execute("""CREATE VIEW v AS SELECT distinct a.name from_name, b.name to_name - FROM defs, refs, objtab a, objtab b - WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod - """) - curs.execute("""CREATE VIEW vnum AS SELECT distinct a.name from_name, b.name to_name, defs.sym sym - FROM defs, refs, objtab a, objtab b - WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod - """) def get_one_object(arg): line = arg.strip() @@ -190,3 +182,17 @@ if dict_sf.has_key("main"): if dict_sm.has_key("main"): print "main is in library", dict_sm["main"] +curs.execute("""CREATE VIEW v AS SELECT distinct a.name from_name, b.name to_name + FROM defs, refs, objtab a, objtab b + WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod + """) +curs.execute("""CREATE VIEW vnum AS SELECT distinct a.name from_name, b.name to_name, defs.sym sym + FROM defs, refs, objtab a, objtab b + WHERE refs.mod = a.rowid and refs.sym = defs.sym and defs.mod = b.rowid and refs.mod != defs.mod + """) +curs.execute("""CREATE VIEW level_1 AS SELECT DISTINCT to_name name + FROM v + WHERE to_name NOT IN (SELECT DISTINCT from_name FROM v) + """) +curs.execute("CREATE TABLE associations AS SELECT * from v") +curs.execute("CREATE TABLE linkages AS SELECT * from vnum")