如何解决Ignite仅返回长时间运行的查询的预期输出的子集
操作系统:Ubuntu 18.04
Apache Ignite:2.9.0(最新)
已加载数据:(从Kaggle获得巴西电子商务数据集)
2张桌子:
订单:10万条记录
order_payments:10万条记录
索引列:
order_payments:CREATE INDEX idx_order_payments ON order_payments (id,order_id,payment_type)
订单:CREATE INDEX idx_orders ON orders (order_id,customer_id,order_status,order_purchase_timestamp)
在Ignite Off-heap和Persistence中总共占用了约400 MB的空间。
我正在执行一个简单的SQL查询:
SELECT orders.order_status,order_payments.payment_type,SUM(order_payments.payment_value) AS total_payments
FROM order_payments
JOIN orders ON orders.order_id = order_payments.order_id
GROUP BY orders.order_status,order_payments.payment_type
ORDER BY total_payments DESC
我正在docker容器中运行Apache Ignite。
这是缓存模板配置:
<property name="cacheConfiguration">
<list>
<bean abstract="true" class="org.apache.ignite.configuration.CacheConfiguration"
id="cache-template-bean">
<!-- when you create a template via XML configuration,you must add an asterisk to
the name of the template -->
<property name="name" value="tbl_pll*"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="backups" value="1"/>
<property name="queryParallelism" value="4"/>
<!-- Other cache parameters -->
</bean>
<bean abstract="true" class="org.apache.ignite.configuration.CacheConfiguration"
id="cache-template-bean">
<!-- when you create a template via XML configuration,you must add an asterisk to
the name of the template -->
<property name="name" value="tbl_hf_pll*"/>
<property name="cacheMode" value="PARTITIONED"/>
<property name="backups" value="1"/>
<property name="queryParallelism" value="2"/>
<!-- Other cache parameters -->
</bean>
</list>
</property>
当我为表使用tbl_pll
缓存模板时,(用于查询的)结果集大约为(1 / queryParallelism)*表中的值数。
因此,在tbl_pll
的情况下,它将返回预期输出的大约1/4。
我对queryParallelism=2
进行了相同的尝试,这使我获得了大约1/2的输出。
我还尝试不使用任何缓存模板,因此使用queryParallelism
参数的默认值(即1),并返回完整结果。
预期的完整输出(以及queryParallelism=1
时的输出):
[['delivered','credit_card',12101094.87999937]
['delivered','boleto',2769932.57999998]
['delivered','voucher',343013.19]
['delivered','debit_card',208421.12]]
使用queryParallelism=4
:
[['delivered',4064387.2800000096],['delivered',918272.54],110648.45000000004],64584.53000000001]]
使用queryParallelism=2
:
[['delivered',6129872.129999977],1360427.3799999985],168392.55999999976],107637.38999999996]]
我怀疑: queryparallelism使用分段索引,输出基于最后/第一个索引段中的内容。 reduce不能正常工作,并且所有线程的输出都没有合并,或者Ignite只运行一个线程并在reduce之后返回输出。
由于我已经在索引中添加了order_payments的payment_type列,因此输出似乎几乎完美地除以了线程/索引段的数量。
我在做什么错,我该如何解决?
编辑: 我只运行1个Apache Ignite实例。
此外,EXPLAIN关键字的输出:
SELECT
__Z1.ORDER_STATUS AS __C0_0,__Z0.PAYMENT_TYPE AS __C0_1,SUM(__Z0.PAYMENT_VALUE) AS __C0_2
FROM PUBLIC.ORDERS __Z1
/* PUBLIC.ORDERS.__SCAN_ */
INNER JOIN PUBLIC.ORDER_PAYMENTS __Z0
/* PUBLIC.IDX_ORDER_PAYMENTS: ORDER_ID = __Z1.ORDER_ID */
ON 1=1
WHERE __Z1.ORDER_ID = __Z0.ORDER_ID
GROUP BY __Z1.ORDER_STATUS,__Z0.PAYMENT_TYPE'],['SELECT
__C0_0 AS ORDER_STATUS,__C0_1 AS PAYMENT_TYPE,CAST(CAST(SUM(__C0_2) AS DOUBLE) AS DOUBLE) AS TOTAL_PAYMENTS
FROM PUBLIC.__T0
/* PUBLIC."merge_scan" */
GROUP BY __C0_0,__C0_1
ORDER BY 3 DESC
解决方法
确保表格为co-located。使用affinityKey
parameter of the CREATE TABLE
command将数据分组在一起。
还要检查Ignite SQL引擎selects the best index。通常,一旦将affinityKey
设置为指向order_id
列的指针,则在连接期间需要选择order_id
索引。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。