On Oct 21, 12:32 am, "C. Titus Brown" <[EMAIL PROTECTED]> wrote:

> Yes, but replace it with what... is sqlite the answer?

while I'm at it,

here is a similar benchmark with sqlite, pasted below (... I can't
seem to find a way to  attach files when posting via google
groups ... )

It is faster than I thought, about 8 minutes for insert and indexing
(10 million entries, 500Mb database), queries on millisecond range
after that

--------------------------------------------

import os, sqlite3, time, random

filename = 'btest.sqlite'

N = 10**7

def create():

    start = time.time()

    if os.path.isfile(filename):
        os.remove( filename )

    conn = sqlite3.connect(filename)
    c = conn.cursor()
    c.execute('''create table data (key text, value text)''')

    for key in range(N):
        c.execute('''insert into data values ('%s', '%s')''' % (key,
key))
    conn.commit()

    end = time.time()
    print 'Insert time: %s' % (end-start)

    # indexing
    start = time.time()
    c.execute('''create index keyindex on data (key)''')
    end = time.time()
    print 'Indexing time: %s' % (end-start)

    conn.close()

def read():

    conn = sqlite3.connect(filename)
    c = conn.cursor()

    start = time.time()

    # get an element
    c.execute('select * from data where key=?', (random.randint(1,
N),) )

    print c.fetchone()

    end = time.time()
    print 'Query time: %s' % (end-start)

    conn.close()

#create()
read()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pygr-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pygr-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to