- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
所以,我想知道是否有必要在两个表之间进行哈希连接以对列进行全表扫描?
如果我想加入 COL1 和 COL2,并且 COL1 较小,它会在 COL1 中进行全面扫描,创建一个 HashMap ,然后使用 sabe 哈希函数在 COL2 中进行全面扫描。
这是正确的吗?
最佳答案
每个数据库都可以有自己的实际实现 Hash Join .但是我会说可能的方法类似于 this
The Hash Join algorithm builds an in-memory hash table of the smaller of its two inputs, and then reads the larger input and probes the in-memory hash table to find matches, which are written to a work table. If the smaller input does not fit into memory, the hash join operator partitions both inputs into smaller work tables. These smaller work tables are processed recursively until the smaller input fits into memory.
关于问题:需要对列进行全表扫描
我会说不,这还取决于数据库及其优化能力。如果查询中有足够的条件来限制任一表中的行,那么它将在使用哈希合并算法之前将这些行拉出。
当它为两个输入中较小的输入构建内存中哈希表
时,它会使用最佳方法将这些行从表中拉出,这不一定是表扫描。如果您在查询中没有条件减少该表上的行,那么它会进行表扫描。
当 然后读取较大的输入并探查内存中的哈希表以查找匹配项
时,它也会使用最佳方法提取这些行,这不一定是表扫描。
如果您的查询是:
SELECT
*
FROM BigTable
INNER JOIN LittleTable ON BigTable.Col=LittleTable.Col
并且使用散列连接,它很可能会通过表扫描从 LittleTable 在内存中创建一个散列表,然后表扫描 BigTable 检查这些散列键。
如果您的查询是:
SELECT
*
FROM BigTable
INNER JOIN LittleTable ON BigTable.Col=LittleTable.Col
WHERE LittleTable.Col2 >'2010/01/01' AND LittleTable.Col2<'2010/01/31'
并且使用散列连接,它很可能会从 LittleTable 在内存中创建一个散列表,但不使用表扫描(如果有要使用的索引),然后表扫描 BigTable 检查这些散列键。添加更多过滤器以更改删除 BigTable 上的表扫描。
关于database - Hash Join 需要全表扫描,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2604731/
我正在测试设置SQLAlchemy以映射现有数据库。这个数据库是很久以前自动建立的,它是由我们不再使用的先前的第三方应用程序创建的,因此 undefined 某些预期的事情,例如外键约束。该软件将管理
这个问题在这里已经有了答案: What is the difference between "INNER JOIN" and "OUTER JOIN"? (28 个答案) 关闭 7 年前。 INNE
这个问题在这里已经有了答案: What is the difference between "INNER JOIN" and "OUTER JOIN"? (29 个回答) 关闭7年前. INNER J
假设有两个表: table1.c1 table1.c2 1 1 A 2 1 B 3 1 C 4 2
假设有两个表: table1.c1 table1.c2 1 1 A 2 1 B 3 1 C 4 2
一.先看一些最简单的例子 例子 Table A aid adate 1 a1 2&nb
数据库操作语句 7. 外连接——交叉查询 7.1 查询 7.2 等值连接 7.3 右外
我有两个表 'users' 和 'lms_users' class LmsUser belongs_to :user end class User has_one :lms_user
我试图避免在 Rails 中对我的 joins 进行字符串插值,因为我注意到将查询器链接在一起时灵活性会降低。 也就是说,我觉得 joins(:table1) 比 joins('inner join
我有这个代码 User.find(:all, :limit => 10, :joins => :user_points, :select => "users.*, co
我刚刚开始探索 Symfony2,我很惊讶它拥有如此多的强大功能。我开始做博客教程在: http://tutorial.symblog.co.uk/ 但使用的是 2.1 版而不是 2.0 我的问题是我
什么是 SQL JOIN什么是不同的类型? 最佳答案 插图来自 W3schools : 关于SQL JOIN 和不同类型的 JOIN,我们在Stack Overflow上找到一个类似的问题: http
我有两个 Hive 表,我正在尝试加入它们。这些表没有被任何字段聚集或分区。尽管表包含公共(public)键字段的记录,但连接查询始终返回 0 条记录。所有数据类型都是“字符串”数据类型。 连接查询很
我正在使用 Solr 的(4.0.0-beta)连接功能来查询包含具有父/子关系的文档的索引。连接查询效果很好,但我只能在搜索结果中获得父文档。我相信这是预期的行为。 但是,是否有可能在搜索结果中同时
我正在使用可用的指南/api/书籍自学 Rails,但我无法理解通过三种方式/嵌套 has_many :through 关联进行的连接。 我有用户与组相关联:通过成员(member)资格。 我在多对多
什么是 SQL JOIN,有哪些不同的类型? 最佳答案 插图来自 W3schools : 关于SQL JOIN 和不同类型的 JOIN,我们在Stack Overflow上找到一个类似的问题: htt
我正在尝试访问数据库的两个表。在商店里,我保留了一个事件列表,其中包含 Table Event id, name,datei,houri, dateF,Hourf ,capacity, age ,de
我有 4 个表:booking、address、search_address 和 search_address_log 表:(相关列) 预订:(pickup_address_id, dropoff_a
我在YML中有以下结构:。我正试着创造一个这样的结构:。作业名称和脚本用~分隔,作业用;分隔。。我可以使用以下命令使其正常工作。然而,我想知道是否可以用一个yq表达式来完成,而不是通过管道再次使用yq
我在YML中有以下结构:。我正试着创造一个这样的结构:。作业名称和脚本用~分隔,作业用;分隔。。我可以使用以下命令使其正常工作。然而,我想知道是否可以用一个yq表达式来完成,而不是通过管道再次使用yq
我是一名优秀的程序员,十分优秀!