最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

mysql - Understanding sys.schema_index_statistics - Stack Overflow

programmeradmin0浏览0评论

I am running a procedure that inserts 10,000 thousand records into a table. It's taking ages ( over 30 mins ).

The indexes on the table are the primary id and two other columns that are foreign keys. The foreign keys point to id's in other tables which have their primary id indexed.

When I look at sys.schema_index_statistics for the table that is getting the inserts I see a huge number of rows_selected on one of the foreign key indexes ( the value is 3,785,992,740 ). I assume rows_selected is a query. If this is just simple referential integrity checks why is this doing so many queries given that I have only 1000 items in one of the referenced tables and 21000 in the other and both those two tables have indexes on their id then why am I seeing so many rows_selected ?

I am running a procedure that inserts 10,000 thousand records into a table. It's taking ages ( over 30 mins ).

The indexes on the table are the primary id and two other columns that are foreign keys. The foreign keys point to id's in other tables which have their primary id indexed.

When I look at sys.schema_index_statistics for the table that is getting the inserts I see a huge number of rows_selected on one of the foreign key indexes ( the value is 3,785,992,740 ). I assume rows_selected is a query. If this is just simple referential integrity checks why is this doing so many queries given that I have only 1000 items in one of the referenced tables and 21000 in the other and both those two tables have indexes on their id then why am I seeing so many rows_selected ?

Share Improve this question asked 2 days ago ScrimpyScrimpy 356 bronze badges 1
  • We can help optimize your stored procedure, if you show it. There's good no reason it should take 30 minutes to insert 10000 records. That would be a new question though. – ysth Commented yesterday
Add a comment  | 

1 Answer 1

Reset to default 0

As per mysql manual on sys.schema_index_statistics table:

rows_selected: The total number of rows read using the index

This is not per query, this is historical total.

发布评论

评论列表(0)

  1. 暂无评论