Count table rows

后端 未结 11 1972
一个人的身影
一个人的身影 2020-11-28 21:55

What is the MySQL command to retrieve the count of records in a table?

11条回答
  •  清酒与你
    2020-11-28 22:45

    If you have a primary key or a unique key/index, the faster method possible (Tested with 4 millions row tables)

    SHOW INDEXES FROM "database.tablename" WHERE Key_Name=\"PRIMARY\"
    

    and then get cardinality field (it is close to instant)

    Times where from 0.4s to 0.0001ms

提交回复
热议问题