Automatic index creation

11 views
Skip to first unread message

Mark Lester

unread,
Dec 19, 2015, 2:56:00 AM12/19/15
to Sequelize
I am specifying an extra index with the index: option on define.
Have I trampled on something that would have been done automatically ?. I wasnt getting the indexes for my other relations, so I am adding them myself now also, but doing so by knowing what we are calling the foreign keys, i.e. relatedModel+'Id' .

This is/was the root of my deletion problem on postgres. Its a big schema and we're cascading through these other relations and once the table sizes mushroom it's curtains. It just didnt show up on mysql.

if I have done something wrong and thats why it didnt work please say.

Mick Hansen

unread,
Dec 21, 2015, 3:26:09 AM12/21/15
to Mark Lester, Sequelize
For 4.0 i'd like to relations to add indexes automatically, but that doesn't happen at the moment.
You either need to use the index option per attribute or the overall model definition indexes option.
--
Mick Hansen
@mhansendev
mhansen.io

Mark Lester

unread,
Dec 21, 2015, 5:23:44 AM12/21/15
to Sequelize, mark.chr...@gmail.com
can I clarify,
if you've made relations then it's up to you to add an index to <related-table>Id via the model level indexes, or explicitly specify the column <relatedModel>Id in the attributes and add an index there, which is even "harder".

if that's not listed as a  feature request already, i.e add an index? option to hasOne/belongsTo, I think it should be.
(I guess it is, but I'll add one or a vote if you want it).

MySQL, magically seemed to get away with this (the cascading delete of the uber parent row, resulting in massive cascading deletes on unindexed columns in even more massive tables), but it all went wrong migrating up.

Reply all
Reply to author
Forward
0 new messages