MySQL view performance

后端 未结 1 921
心在旅途
心在旅途 2020-11-29 05:13

I have a table for about 100,000 users in it.

First Case:

explain select state, count(*) as cnt from users where state = \'ca\'

Whe

相关标签:
1条回答
  • 2020-11-29 05:53

    It's about the view algorithm that's been used.

    The merge algorithm works well most table indexes and whatnot - the temptable algorithm doesn't - in many cases your indexes will just be flat-out not used at all.

    And there's lots of crap that merge doesn't support

    MERGE cannot be used if the view contains any of the following constructs:

    * Aggregate functions (SUM(), MIN(), MAX(), COUNT(), and so forth)
    * DISTINCT
    * GROUP BY
    * HAVING
    * LIMIT
    * UNION or UNION ALL
    * Subquery in the select list
    * Refers only to literal values (in this case, there is no underlying table)
    
    0 讨论(0)
提交回复
热议问题