#!/usr/bin/python import os, sqlite3, time c = sqlite3.connect('wcx.db') c.execute("""pragma case_sensitive_like=1""") c.execute("""pragma foreign_keys=on""") c.execute("""pragma synchronous=off""") c.execute("""pragma temp_store=memory""") start = time.clock() # cpu clock as float in secs #c.execute("""drop index i_wc_id_rp;""") #c.execute("""create index i_wc_id_rp on nodes (wc_id, local_relpath);""") print c.execute(".indices") # strategy 1 c.execute("""select * from nodes where wc_id = 1 AND (local_relpath like 'foo/%' OR local_relpath = 'foo');"""); # strategy 2 #c.execute("""select * from nodes where wc_id = 1 AND local_relpath like 'foo/%' # union select * from nodes where wc_id = 1 AND local_relpath = 'foo';""") # strategy 3 #c.execute("""select * from nodes where wc_id = 1 AND local_relpath like 'foo/%';""") #c.execute("""select * from nodes where wc_id = 1 AND local_relpath = 'foo';""") end = time.clock() print "timing: %5f\n" % (end - start)