Load indexes for this table
541417
protected function addIndexes(Table $table)
    {
        $dataFetcher = $this->dbh->query("sp_indexes_rowset '" . $table->getName() . "'");
        $dataFetcher->setStyle(\PDO::FETCH_ASSOC);

        $indexes = [];
        foreach ($dataFetcher as $row) {
            $colName = $this->cleanDelimitedIdentifiers($row['COLUMN_NAME']);
            $name = $this->cleanDelimitedIdentifiers($row['INDEX_NAME']);

            $isPk = $this->cleanDelimitedIdentifiers($row['PRIMARY_KEY']);
            $isUnique = $this->cleanDelimitedIdentifiers($row['UNIQUE']);

            $localColumn   = $table->getColumn($colName);

            // ignore PRIMARY index
            if ($isPk) {
                continue;
            }

            if (!isset($indexes[$name])) {
                if ($isUnique) {
                    $indexes[$name] = new Unique($name);
                } else {
                    $indexes[$name] = new Index($name);
                }
                $indexes[$name]->setTable($table);
            }

            $indexes[$name]->addColumn($localColumn);
        }

        foreach ($indexes as $index) {
            if ($index instanceof Unique) {
                $table->addUnique($index);
            } else {
                $table->addIndex($index);
            }
        }
    }
712567
def columns(self):
        
        return Index(np.array(self._gather_column_names(), dtype=np.bytes_), np.dtype(np.bytes_))
1020673
def _get_indexes(self, schema, **kwargs):
        """"""
        ret = {}
        query_str = []
        query_str.append('SELECT')
        query_str.append('  tbl.relname AS table_name, i.relname AS index_name, a.attname AS field_name,')
        query_str.append('  ix.indkey AS index_order, a.attnum AS field_num')
        query_str.append('FROM')
        query_str.append('  pg_class tbl, pg_class i, pg_index ix, pg_attribute a')
        query_str.append('WHERE')
        query_str.append('  tbl.oid = ix.indrelid AND i.oid = ix.indexrelid AND a.attrelid = tbl.oid')
        query_str.append('  AND a.attnum = ANY(ix.indkey) AND tbl.relkind = %s AND tbl.relname = %s')
        query_str.append('ORDER BY')
        query_str.append('  tbl.relname, i.relname')
        query_str = os.linesep.join(query_str)

        indexes = self.query(query_str, 'r', str(schema), **kwargs)

        # massage the data into more readable {index_name: fields} format
        for idict in indexes:
            if idict['index_name'] not in ret:
                ret[idict['index_name']] = list(map(int, idict['index_order'].split(' ')))

            i = ret[idict['index_name']].index(idict['field_num'])
            ret[idict['index_name']][i] = idict['field_name']

        return ret
909458
public function getIndexes()
    {
        if (!$this->indexCache) {
            // Get the details columns information.
            $this->db->setQuery('SHOW KEYS FROM ' . $this->db->quoteName($this->getName()));

            $this->indexCache = $this->db->loadAll();
        }

        return $this->indexCache;
    }
1314542
public function indexes($table)
    {
        return Cache::remember("{$table}_indexes", $this->lifetime(), function () use ($table) {
            return $this->manager->listTableIndexes($table);
        });
    }
166883
def insert_index(self, table, name, url, std=""):
        """"""
        names = self.parse_title(name);

        for n in names:
            self.db_cursor.execute(
                'INSERT INTO "%s" (name, url, std) VALUES (?, ?, ?)' % table, (
                n, url, std))
200227
def load_keys(database, parameters):
    """"""
    keys = []
    with database.snapshot() as snapshot:
        results = snapshot.execute_sql(
            'SELECT u.id FROM %s u' % parameters['table'])

    for row in results:
        keys.append(row[0])

    return keys
607217
def _BuildIndex(self):
        """"""
        self._index = {}
        for i, k in enumerate(self._keys):
            self._index[k] = i
605465
def _load_info(self):
    """"""
    if self._info is None:
      try:
        self._info = self._api.tables_get(self._name_parts)
      except Exception as e:
        raise e
199023
public function getIndexes()
    {
        $this->db->setQuery(
            '
SELECT
    t.relname AS table_name,
    i.relname AS index_name,
    a.attname AS column_name,
    ix.indisunique AS is_unique,
    ix.indisprimary AS is_primary
FROM pg_class AS t,
    pg_class AS i,
    pg_index AS ix,
    pg_attribute AS a
WHERE t.oid = ix.indrelid
    AND i.oid = ix.indexrelid
    AND a.attrelid = t.oid
    AND a.attnum = ANY(ix.indkey)
    AND t.relkind = \'r\'
    AND t.relname = ' . $this->db->quote($this->db->replacePrefix($this->getName())) . '
ORDER BY t.relname, i.relname;'
        );

        $keys = $this->db->loadAll();

        foreach ($keys as $key) {
            $key->Table = $this->getName();
            $key->Non_unique = !$key->is_unique;
            $key->Key_name = $key->index_name;
            $key->Column_name = $key->column_name;
            $key->Collation = 'A';
            $key->Cardinality = 0;
            $key->Sub_part = null;
            $key->Packed = null;
            $key->Null = null;
            $key->Index_type = 'BTREE';
            // TODO: Finish comments query
            $key->Comment = null;
            $key->Index_comment = null;
        }

        return $keys;
    }
752270
protected function _fetchTableIndexes($table)
    {
        $result = array();
        $sql    = $this->quoteName($this->getTableNeedle().$table);

        if ($indexes = $this->show('SHOW INDEX FROM '.$sql, AnDatabase::FETCH_OBJECT_LIST)) {
            foreach ($indexes as $index) {
                $result[$index->Key_name][$index->Seq_in_index] = $index;
            }
        }

        return $result;
    }
950972
function () {
        var list = slice.call(this.indexes || []);
        var i = 0;
        list.push(this.mainIndex);
        list.push('cid');
        var l = list.length;
        this.models = [];
        this._indexes = {};
        for (; i < l; i++) {
            this._indexes[list[i]] = {};
        }
    }
1048370
def load_table(self, table):
        
        table = self._valid_table_name(table)
        schema, table = self.parse_table_name(table)
        if not schema:
            schema = self.schema
            tables = self.tables
        else:
            tables = self.tables_in_schema(schema)
        if table in tables:
            return Table(self, schema, table)
        else:
            return None
656017
def indexes(table_name, name = nil)
       schemas = schema_search_path.split(/,/).map { |p| quote(p) }.join(',')

       # Changed from upstread: link to pg_am to grab the index type (e.g. "gist")
       result = query(<<-SQL, name)
         SELECT distinct i.relname, d.indisunique, d.indkey, t.oid, am.amname
           FROM pg_class t, pg_class i, pg_index d, pg_attribute a, pg_am am
         WHERE i.relkind = 'i'
           AND d.indexrelid = i.oid
           AND d.indisprimary = 'f'
           AND t.oid = d.indrelid
           AND t.relname = '#{table_name}'
           AND i.relnamespace IN (SELECT oid FROM pg_namespace WHERE nspname IN (#{schemas}) )
           AND i.relam = am.oid
           AND a.attrelid = t.oid
        ORDER BY i.relname
      SQL


      indexes = []

      indexes = result.map do |row|
        index_name = row[0]
        unique = row[1] == 't'
        indkey = row[2].split(" ")
        oid = row[3]
        indtype = row[4]

        # Changed from upstream: need to get the column types to test for spatial indexes
        columns = query(<<-SQL, "Columns for index #{row[0]} on #{table_name}").inject({}) {|attlist, r| attlist[r[1]] = [r[0], r[2]]; attlist}
        SELECT a.attname, a.attnum, t.typname
        FROM pg_attribute a, pg_type t
        WHERE a.attrelid = #{oid}
        AND a.attnum IN (#{indkey.join(",")})
        AND a.atttypid = t.oid
        SQL

        # Only GiST indexes on spatial columns denote a spatial index
        spatial = indtype == 'gist' && columns.size == 1 && (columns.values.first[1] == 'geometry' || columns.values.first[1] == 'geography')

        column_names = indkey.map {|attnum| columns[attnum] ? columns[attnum][0] : nil }
        ActiveRecord::ConnectionAdapters::IndexDefinition.new(table_name, index_name, unique, column_names, spatial)
      end

      indexes
    end
1122858
def load_table(self, table, rows, colnames=None, limit=None):
        

        conn = self.engine.raw_connection()
        cur = conn.cursor()

        colnames = colnames or next(rows)

        cmd = 'INSERT INTO {table} ({colnames}) VALUES ({placeholders})'.format(
            table=self.tables[table],
            colnames=', '.join(colnames),
            placeholders=', '.join([self.placeholder] * len(colnames)))

        cur.executemany(cmd, itertools.islice(rows, limit))
        conn.commit()
172532
def is_indexed(self):
        
        try:
            return getattr(self.table.cols, self.cname).is_indexed
        except AttributeError:
            False
14341
def indexes(table, stream)
        if (indexes = @connection.indexes(table)).any?
          add_index_statements = indexes.map do |index|
            table_name = remove_prefix_and_suffix(index.table).inspect
            "  add_index #{([table_name] + index_parts(index)).join(', ')}"
          end

          stream.puts add_index_statements.sort.join("\n")
          stream.puts
        end
      end