Package gavo :: Package rscdef :: Module tabledef :: Class DBIndex
[frames] | no frames]

Class DBIndex

source code

                   object --+            
                            |            
 base.structure.StructureBase --+        
                                |        
                   object --+   |        
                            |   |        
           base.common.Parser --+        
                                |        
base.structure.ParseableStructure --+    
                                    |    
             base.structure.Structure --+
                                        |
                                       DBIndex

A description of an index in the database.

In real databases, indices may be fairly complex things; still, the most common usage here will be to just index a single column:

       <index columns="my_col"/>

To index over functions, use the character content; parentheses are added by DaCHS, so don't have them in the content. An explicit specification of the index expression is also necessary to allow RE pattern matches using indices in character columns (outside of the C locale). That would be:

       <index columns="uri">uri text_pattern_ops</index>

(you still want to give columns so the metadata engine is aware of the index). See section "Operator Classes and Operator Families" in the Postgres documentation for details.

For pgsphere-valued columns, you at the time of writing need to specify the method:

       <index columns="coverage" method="GIST"/>

To define q3c indices, use the ``//scs#q3cindex`` mixin; if you're devious enough to require something more flexible, have a look at that mixin's definition.

If indexed columns take part in a DaCHS-defined view, DaCHS will not notice. You should still declare the indices so users will see them in the metadata; writing:

       <index columns="col1, col2, col3"/>

is sufficent for that.

Nested Classes

Inherited from base.structure.StructureBase: __metaclass__

Instance Methods
 
completeElement(self, ctx) source code
 
__eq__(self, other) source code
 
__lt__(self, other) source code
 
iterCode(self) source code
 
create(self, querier)
creates the index on the parent table if necessary.
source code
 
drop(self, querier)
drops the index if it exists.
source code
 
__ge__(x, y)
x>=y
 
__gt__(x, y)
x>y
 
__le__(x, y)
x<=y

Inherited from base.structure.Structure: __provides__, callCompletedCallbacks, finishElement, onElementComplete, validate

Inherited from base.structure.ParseableStructure: __init__, end_, feed, feedFrom, feedObject, getAttribute, iterEvents, start_, value_

Inherited from base.structure.StructureBase: __providedBy__, adopt, breakCircles, change, copy, getAttributes, getCopyableAttributes, getSourcePosition, iterChildren, setPosition

Inherited from base.common.Parser: feedEvent

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Methods

Inherited from base.structure.StructureBase: fromStructure

Class Variables
  name_ = 'index'
a sentinel for all kinds of undefined values.
  attrSeq = [<gavo.base.attrdef.BooleanAttribute object>, <gavo....
  managedAttrs = {'cluster': <gavo.base.attrdef.BooleanAttribute...

Inherited from base.structure.Structure: __implemented__

Inherited from base.structure.StructureBase: completedCallbacks

Properties
  dbname

Inherited from object: __class__

Method Details

completeElement(self, ctx)

source code 
Overrides: base.structure.Structure.completeElement

create(self, querier)

source code 

creates the index on the parent table if necessary.

querier is an object mixing in the DBMethodsMixin, usually the DBTable object the index should be created on.

drop(self, querier)

source code 

drops the index if it exists.

querier is an object mixing in the DBMethodsMixin, usually the DBTable object the index possibly exists on.


Class Variable Details

attrSeq

Value:
[<gavo.base.attrdef.BooleanAttribute object>,
 <gavo.base.structure.DataContent object>,
 <gavo.base.attrdef.StringListAttribute object>,
 <gavo.base.parsecontext.IdAttribute object>,
 <gavo.base.attrdef.UnicodeAttribute object>,
 <gavo.base.attrdef.UnicodeAttribute object>]

managedAttrs

Value:
{'cluster': <gavo.base.attrdef.BooleanAttribute object>,
 'columns': <gavo.base.attrdef.StringListAttribute object>,
 'content_': <gavo.base.structure.DataContent object>,
 'id': <gavo.base.parsecontext.IdAttribute object>,
 'method': <gavo.base.attrdef.UnicodeAttribute object>,
 'name': <gavo.base.attrdef.UnicodeAttribute object>}

Property Details

dbname

Get Method:
unreachable.dbname(self)