-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm storing a lot of documents (TREC-9 corpus) in a Doc class/table
created using declarative_base():

class Doc(Base):
    __tablename__ = 'doc'
    id = Column(Integer, primary_key=True)
    I = Column(Integer, index=True) #  .I      sequential identifier
    U = Column(Integer, index=True) #  .U      MEDLINE identifier (UI)
 (<DOCNO> used for relevance judgements)
    M = Column(String, index=True)  #  .M      Human-assigned MeSH
terms (MH)
...


The problem is INSERTs on such table (PG 9.1) are slowing down more
and more as docs are added. So I dropped indexes:


def drop_indexes(cls, eng):
    conn = eng.connect()
    indexes = cls.metadata.tables[cls.__tablename__].indexes
    for idx in indexes:
        conn.execute(DropIndex(idx))


(incidentally, is there a better/simpler way of dropping all indexes
for a given mapping class?)


Now all batches of INSERTs (grouped in 10,000 records transactions)
have around linear execution time.

Dandy. But how can I recreate the indexes now that I dropped them and
they were created automatically by passing kw argument (index=True) to
Column?


Regards,
mk



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.20 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSHcaDAAoJEFMgHzhQQ7hOcX8H/jNaDd1uGJaxxNBrF49DIabU
lkzk13kS/aPwUPqtFecdteaNKp9oxsyFdaWLWBRk2TFmU0JqIlLo6H6V9vm2+zXQ
XvQJbWEYbkTtVCt2rIh4bxOUCicpUJWFETZU0YD69P1mrcSFeg5U9+B4EeVWvEKG
8cb9XwL7WzAV8PEsfDsC4zSpN8sEugadqiekK9Mlh2Tazkj5OMWiTz0YU3ffY+BJ
9oLghLEfpxz5Gj8DRpD09SyMdLqilWG8e4BsCrVIOiC19GJAUHG7Zpr6rK5mXYah
7EoJQvtWUQyavKk3OhyX3QfZnY+2DB+A1Y6pzizwOWAOmGFYjWEVINUoZ0a9/2U=
=+g/N
-----END PGP SIGNATURE-----

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to