Confusion on how to do add basic indexing in sqlalchemy after table creation
<p>I am trying to get a simple example of indexing working with a database that has 100,000 entries and see how it improves speed. The table looks something like this:</p>

<pre><code>user = Table('user', metadata,
    Column('id', Integer, primary_key=True),
    Column('first_name', String(16), nullable=False),
    Column('last_name', String(16), nullable=False),
    Column('age', Integer, nullable=False),
    Column('joined_at', DateTime(), nullable=False, index=True),
)
</code></pre>

<p>I am given a user key/value dict with keys 'first_name', 'last_name', 'age', and 'joined_at' query looks like this:</p>

<pre><code>q = session.query(UserTable).filter(and_(
        UserTable.first_name == user['first_name'],
        UserTable.last_name == user['last_name'],
        UserTable.age == user['age'],
        UserTable.joined_at == user['joined_at']))
</code></pre>

<p>I was wondering what syntax would properly use create() on the new index for joined_at to only look at the joined_at columns that are at the same Datetime as user['joined_at'] since the index was added after the table was created</p>

<p>Indexing in SQL and thus in SQLAlchemy is happening behind the scene.</p>

<p>Indexing is a feature of the underlying SQL engine and doesn't need any special query in order to utilize the performance gain. The mere definition is sufficient.</p>

python mysql indexing sqlalchemy