What are your most common sql optimizations?

后端 未结 17 1627
谎友^
谎友^ 2020-12-12 14:51

What are your most common SQL optimization that you used?

17条回答
  •  一个人的身影
    2020-12-12 15:20

    I have read all answers and I didn't found LIMIT and OFFSET usage hints. It is very common usage in pagination with "prev" and "next" links. But rendering such a display can consume more resources than the entire rest of the site. When offsetting large number items, query can become very slow. So avoid these queries.

    • Do not count total items.
    • Show only "n" number first items (for example only top 100).

    Such methods uses Google, Twitter and other sites. In Google search there is no accurate number of results. There is only approximate number. Twitter doesn't allow user to view all past tweets. It shows only last n number (I can't remember how much).

    There is some link from MySQL performance blog.

提交回复
热议问题