On May 30, 2012, at 7:38 AM, Christian Klinger wrote:

> Hi,
> 
> Hi i use sqlalchemy to map an existing oracle table to my class via the 
> declarative syntax. One of the columns is indexed.
> 
> Do i understand it correctly to only specify the index in my Column?
> 
> class Example(...)
>   mnr = Column("MNR", String(12), primary_key=True, index=True)
> 
> 
> And how can i check if the index is used in a select? Do i see it with
> echo=True?

an index in SQL is a construct that is specified using a CREATE statement, and 
only once for that database, in the same way the CREATE statement is used for a 
table.   

If you are using your declarative models to emit the CREATE statements to your 
Oracle database, with index=True you will also see a corresponding CREATE INDEX 
in the DDL that is emitted.

If you are *not* emitting CREATE statements, and your Oracle database already 
has an existing schema, then the index=True flag has no effect.  It is only 
meaningful when CREATE statements are emitted.

To see if your SELECT is using particular indexes, you'd want to view the query 
plan, which you get by using EXPLAIN.   See 
http://docs.oracle.com/cd/B10500_01/server.920/a96533/ex_plan.htm for 
background on this specific to Oracle.


-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to