php mysql查询中的数组

when i use arrays mysql query it's really slow. are there any tricks that makes this faster?

e.g:

  SELECT * 
    FROM posts
   WHERE type IN ('1','2','5')
ORDER BY id ASC

takes much longer then other queries.

If type is integer type, then remove apostrophes:

WHERE type IN (1, 2, 5)

If not - change type type to integer

There a number of things to speed up queries I'd consider looking up the following:

Normalizing. Perhaps the structure of your tables isn't the most efficient?

Indexing. This will improve query times if you KNOW what you want to search on.

EXPLAIN will tell you why your query is slow. Based on that you can make adjustments to your query or your table structure to solve the problem. In this case, use it like this:

EXPLAIN SELECT * FROM posts WHERE type IN (1,2,5) ORDER BY id ASC

Here you need to look two things First, ('1','2','5') this is string not integer it should be (1,2,5). Second, you can apply indexes on type field.