Can foreign keys hurt query performance

前端 未结 11 1821
温柔的废话
温柔的废话 2021-02-02 10:55

As I understood from this post, there are some scenarios where foreign keys can improve query performance.

I\'ve heard the opposite claim though, that because of refere

11条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-02 11:27

    Foreign keys will not adversley affect query performance in most cases, and are strongly recommended. By aiding normalization, you will eliminate redundant data, and if you follow up by adding underlying indexes (for the appropriate foreign key) you will get good performance on your queries.

    Foreign-keys can help the query optimizer get the best query plans for a given query.

    Foreign-key checking is a factor when you update your data (which is a separate consideration - I assume here your concern is query - unless by the word query you imply both).

提交回复
热议问题