How can I count the numbers of rows that a MySQL query returned?

后端 未结 11 1913
北海茫月
北海茫月 2020-11-28 04:51

How can I count the number of rows that a MySQL query returned?

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-28 05:41

    This is not a direct answer to the question, but in practice I often want to have an estimate of the number of rows that will be in the result set. For most type of queries, MySQL's "EXPLAIN" delivers that.

    I for example use that to refuse to run a client query if the explain looks bad enough.

    Then also daily run "ANALYZE LOCAL TABLE" (outside of replication, to prevent cluster locks) on your tables, on each involved MySQL server.

提交回复
热议问题