Pg: Add index marker

Created on 14 Apr 2018  路  3Comments  路  Source: go-pg/pg

I know, https://github.com/go-pg/pg/issues/125 closed.
But maybe possible to support "index" marker?

type Logs struct {
    ID        int64
    Log       string
    CreatedAt time.Time `sql:",index"`
}

And go-pg will create index for created_at field?

Most helpful comment

It would be better to support at least the standard stuff like creating a simple index for a date as @Labutin suggested. This way most scenarios can be covered with the least effort from the library and from the using developer's side.

Please reconsider adding this feature with rudimentary or no options.

All 3 comments

If somebody's gonna implement this, please, don't forget about other options for create index query such as method(btree, hash, gist, and gin).

I believe it is easier to use raw sql in this case via https://github.com/go-pg/pg/wiki/Writing-Queries#executing-custom-queries, because there are lots of options and order of columns matters a lot.

It would be better to support at least the standard stuff like creating a simple index for a date as @Labutin suggested. This way most scenarios can be covered with the least effort from the library and from the using developer's side.

Please reconsider adding this feature with rudimentary or no options.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jayschwa picture jayschwa  路  4Comments

owentran picture owentran  路  6Comments

rhymes picture rhymes  路  5Comments

RepentantGopher picture RepentantGopher  路  5Comments

mamal72 picture mamal72  路  3Comments