查询大表 [英] query large table

查看:29
本文介绍了查询大表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查询大表(> 150 万行)3 次还是将 3 个条件放在同一个查询中更好?示例 where 子句如下.有类似或更复杂的 where 子句.我的预感是将它们全部放在相同的 where 中.但需要社区的一些投入.提前致谢.

Is it better to query large table (> 1.5 million rows) 3 times or to put 3 condition in the same query? The sample where clause is below. There are similar or more complicated where clauses. My hunch is to put all of them in same where. But need some input from community. Thanks in advance.

where (a =1 or b=1) and (a=2 or b=3) and (c=1 or d=3)

推荐答案

单次访问数据库绝对更可取.确保为 abcd 列建立索引,你应该没问题.

A single trip to the database is definitely preferable. Make sure you index the a, b, c and d columns and you should be fine.

这篇关于查询大表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆