Verified Commit 825d4326 authored by Martin Petráček's avatar Martin Petráček
Browse files

change DB indexes

parent 248fe80d
......@@ -21,6 +21,7 @@ con = sqlite3.connect('/var/lib/pakon.db')
c = con.cursor()
c.execute('CREATE TABLE IF NOT EXISTS traffic (flow_id integer, start real, duration integer, src_mac text, src_ip text, src_port integer, dest_ip text, dest_port integer, proto text, app_proto text, bytes_send integer, bytes_received integer, app_hostname text)')
c.execute('CREATE INDEX IF NOT EXISTS start ON traffic(start)')
c.execute('CREATE INDEX IF NOT EXISTS archive1 ON traffic(src_mac, start, COALESCE(app_hostname,dest_ip))')
c.execute('CREATE UNIQUE INDEX IF NOT EXISTS flow_id ON traffic(flow_id) WHERE flow_id IS NOT NULL')
c.execute('PRAGMA user_version=1')
con.commit()
......@@ -31,7 +32,10 @@ os.makedirs(os.path.dirname(os.path.abspath(archive_path)), exist_ok=True)
con = sqlite3.connect(archive_path)
c = con.cursor()
c.execute('CREATE TABLE IF NOT EXISTS traffic (start real, duration integer, details integer, src_mac text, src_ip text, src_port integer, dest_ip text, dest_port integer, proto text, app_proto text, bytes_send integer, bytes_received integer, app_hostname text)')
c.execute('CREATE INDEX IF NOT EXISTS traffic_lookup ON traffic(details, start, src_mac)')
c.execute('DROP INDEX IF EXISTS traffic_lookup')
c.execute('CREATE INDEX IF NOT EXISTS archive1 ON traffic(details, src_mac, COALESCE(app_hostname,dest_ip), start)')
c.execute('CREATE INDEX IF NOT EXISTS start ON traffic(start)')
c.execute('CREATE INDEX IF NOT EXISTS dest_port ON traffic(dest_port)')
c.execute('PRAGMA user_version=1')
con.commit()
con.close()
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