Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scql计算结果与MySQL的结果误差较大 #173

Closed
Rufus369 opened this issue Nov 16, 2023 · 2 comments
Closed

scql计算结果与MySQL的结果误差较大 #173

Rufus369 opened this issue Nov 16, 2023 · 2 comments

Comments

@Rufus369
Copy link

我用相同的sql在scql和mysql执行,得到的结果误差挺大的,可以解释下原因嘛
scql:
SELECT ta.credit_rank, COUNT(*) as cnt, AVG(ta.income) as avg_income, AVG(tb.order_amount) as avg_amount FROM ta INNER JOIN tb ON ta.ID = tb.ID WHERE ta.age >= 20 AND ta.age <= 30 AND tb.is_active=1 GROUP BY ta.credit_rank;

[fetch]
2 rows in set: (324.059274ms)
+-------------+-----+-------------------+--------------------+
| credit_rank | cnt | avg_income | avg_amount |
+-------------+-----+-------------------+--------------------+
| 5 | 6 | 18069.77597427368 | 7743.3486404418945 |
| 6 | 4 | 336016.2181968689 | 5499.414562225342 |

mysql
SELECT alice.user_credit.credit_rank, COUNT(*) as cnt, AVG(alice.user_credit.income) as avg_income, AVG(bob.user_stats.order_amount) as avg_amount FROM alice.user_credit INNER JOIN bob.user_stats ON alice.user_credit.ID = bob.user_stats.ID WHERE alice.user_credit.age >= 20 AND alice.user_credit.age <= 30 AND bob.user_stats.is_active=1 GROUP BY alice.user_credit.credit_rank;

+-------------+-----+-------------+-------------------+
| credit_rank | cnt | avg_income | avg_amount |
+-------------+-----+-------------+-------------------+
| 6 | 4 | 336017.5000 | 5499.425048828125 |
| 5 | 6 | 18070.0000 | 7743.466796875 |
+-------------+-----+-------------+-------------------+
2 rows in set (0.00 sec)

@tongke6
Copy link
Collaborator

tongke6 commented Nov 16, 2023

@Rufus369 从上面的执行结果来看,结果的绝对误差都很小(0.1~1.0左右之间),相对误差更小了~

MPC 计算是存在误差的,详情可见:https://www.secretflow.org.cn/docs/spu/latest/en-US/development/fxp

Copy link

Stale issue message. Please comment to remove stale tag. Otherwise this issue will be closed soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants