import sys, os, pgdb, time

db = pgdb.connect(host="hancock.lcs.mit.edu", database="6.830", user="drkp")
cursor = db.cursor()

query = "select count(*) from movies where id < "

for n in range(0, 1000000, 10000):
    x = time.time()
    cursor.execute(query + str(n))
    cursor.fetchall()
    print n, time.time() - x
