search

Home  >  Q&A  >  body text

mysql - 订单表,我把它分成好几个,我要查询订单,怎么用一条sql语句高效查询

高洛峰高洛峰2787 days ago680

reply all(3)I'll reply

  • PHPz

    PHPz2017-04-17 15:06:17

    Inline query, join condition plus index, and all fields related to where need to be indexed

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-17 15:06:17

    It is best to determine which table to use for query based on the query conditions of the order, so that there is no need to query multiple tables.
    If this is not possible, the general approach is to query multiple tables separately, and then use union all to put them into one result set.

    reply
    0
  • 阿神

    阿神2017-04-17 15:06:17

    There are several ways:
    1. Partition, partition according to the conditions of your partitioning. After partitioning, the corresponding partition will be found according to your partitioning conditions
    2. The tables of the myisam storage engine can be merged into one surface. However, the table structure is required to be consistent, see MRG_MYISAM
    3. Multiple tables union all. It is more appropriate to require an index
    4. Application judgment processing.

    reply
    0
  • Cancelreply