SQL Server reflects an implicit "heap" index

Issue #4059 resolved
Mike Bayer repo owner created an issue

not sure if this is SQL server 2017 only, or 2016 forward, have not seen this with earlier testing:

from sqlalchemy import *

e = create_engine("mssql+pymssql://scott:tiger^5HHH@mssql2017:1433/test", echo=True)


c = e.connect()
c.execute("drop table if exists foo")
c.execute("""
    create table foo (
        d1 integer,
        d2 integer
    )
""")
c.execute("create index food1 on foo(d1)")

insp = inspect(e)
print insp.get_indexes("foo")

output:

[{'unique': False, 'name': None, 'column_names': []}, {'unique': False, 'name': u'food1', 'column_names': [u'd1']}]

that name=None is a heap index that is implicit, see https://docs.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-indexes-transact-sql

Comments (1)

  1. Mike Bayer reporter

    Ignore SQL Server "heap" indexes

    Added a rule to SQL Server index reflection to ignore the so-called "heap" index that is implicitly present on a table that does not specify a clustered index.

    Tests are part of standard suite already (CI has been disabled)

    Change-Id: I593b95551c40ee5d95d54203611112cbff10856f Fixes: #4059

    → <<cset 3e855cd277aa>>

  2. Log in to comment