Create custom Indexes on Login_History table

Our Login History table has a lot of records, making queries to this table quite expensive in terms of the rows extracted.

Is it safe to manually add an index on user_id and device_id ?

I'm perfectly aware that when we update the version it my delete the index. But that even is rare enough that I think its fine.

@Laraib in general I wouldn't recommend making changes to the appDB. This could cause issues with migrations down the line if the migration makes an assumption that's not true (though indexes are a little less risky than schema changes, etc).

What query is it that you're concerned with improving performance on? Is this related to data replication, behavior within Metabase itself, etc?

1 Like

@Laraib this index will exist in a future release:

Thanks @leeloo this is exactly what I was looking for.

SELECT login_history . id FROM login_history WHERE ( user_id = ? ) AND ( device_id = ? ) LIMIT ?