sequelize/sequelize

Option to auto create foreign key indexes

Open

#5042 opened on Dec 14, 2015

View on GitHub
 (11 comments) (9 reactions) (0 assignees)TypeScript (29,527 stars) (4,271 forks)batch import
existing workaroundgood first issuestatus: understood

Description

If you create a foreign key constraint no further index will be auto created by postgres (I'm not sure what other DBs will do, I did not check), since there are a couple of different ways to create a index in that case.

But I'd say the average use case would be improved if sequelize would just add a normal btree index on the foreign key if you pass a option to the global sequelize instance. That way new tables would always benefit from that and you do not always have to think about it.

The performance difference is significant in that case.

So I'd say it would be a nice feature to add.

Contributor guide