aboutsummaryrefslogtreecommitdiff
path: root/data/cut.py
diff options
context:
space:
mode:
authorAlex Auvolat <alex.auvolat@ens.fr>2015-05-22 10:00:15 -0400
committerAlex Auvolat <alex.auvolat@ens.fr>2015-05-22 10:00:15 -0400
commit39e549f05e568e4153381f025b3a0f256e9a7b7a (patch)
tree4e06cc45f359ad6a8cf4243fe7b42d01a23f7512 /data/cut.py
parentdf50f103c1167f54a3ec04c1380fc95e4a023428 (diff)
downloadtaxi-39e549f05e568e4153381f025b3a0f256e9a7b7a.tar.gz
taxi-39e549f05e568e4153381f025b3a0f256e9a7b7a.zip
Make indexing faster by indexing only one column and querying a range
Diffstat (limited to 'data/cut.py')
-rw-r--r--data/cut.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/data/cut.py b/data/cut.py
index 1253434..7853030 100644
--- a/data/cut.py
+++ b/data/cut.py
@@ -24,8 +24,10 @@ class TaxiTimeCutScheme(IterationScheme):
with sqlite3.connect(self.dbfile) as db:
c = db.cursor()
for cut in cuts:
- l = l + [i for (i,) in
- c.execute('SELECT trip FROM trip_times WHERE begin <= ? AND end >= ?', (cut, cut))]
+ part = [i for (i,) in
+ c.execute('SELECT trip FROM trip_times WHERE begin >= ? AND begin <= ? AND end >= ?',
+ (cut - 40000, cut, cut))]
+ l = l + part
return iter_(l)