indexes
-
MongoDB
Fix MongoDB E11000 Duplicate Key Error (Mongoose Guide)
E11000 means an insert or update would create two documents with the same value in a field that has a unique index. Read the index name and dup key in the message. If it is a real duplicate, return a 409 error to the user. If the value is null, use a partial index; if the index is left over from an old schema, drop it with db.collection.dropIndex().
-
Database
SQL Views and Indexes: How They Work Together (Views vs Materialized Views)
A plain view is a saved query: it stores no data, so it can’t have its own indexes, but queries through it use the indexes on the underlying tables. A materialized view stores the query’s results as a table, so you can index it and read it very fast, but it only changes when you refresh it. Use views for convenience and security, and indexed materialized views for expensive reports that can be slightly out of date.


