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

Start tracking incoming message counts by flow #5679

Merged
merged 3 commits into from
Nov 22, 2024
Merged

Conversation

rowanseymour
Copy link
Member

No description provided.

Copy link

codecov bot commented Nov 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (87deb12) to head (5aef096).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #5679   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files          569       570    +1     
  Lines        25870     25881   +11     
=========================================
+ Hits         25870     25881   +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

SELECT n.flow_id, format('msgsin:date:%s', n.created_on::date), count(*), FALSE FROM newtab n
INNER JOIN oldtab o ON o.id = n.id
WHERE n.direction = 'I' AND o.flow_id IS NULL AND n.flow_id IS NOT NULL
GROUP BY 1, 2;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe this should be a single row trigger since we don't write incoming messages in bulk... then it could at least write the 3 flows_flowactivitycount rows in bulk...

FlowNodeCount.squash()
FlowRunStatusCount.squash()
FlowCategoryCount.squash()
FlowStartCount.squash()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

splitting up these tasks so we can see the performance of the new counts.. including FlowStartCount with new counts because still not sure if it needs to be changed

SELECT n.flow_id, count(*) AS msgs FROM newtab n INNER JOIN oldtab o ON o.id = n.id
WHERE n.direction = 'I' AND o.flow_id IS NULL AND n.flow_id IS NOT NULL
GROUP BY 1
) s;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ericnewcomer @norkans7 tweaked this so that the 3 count rows are added with a single insert.. only downside here is that NOW() can't be mocked in tests.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also can't fake historical messages but we don't want to ever do that again anyway

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What index is used for WHERE n.direction = 'I' AND o.flow_id IS NULL AND n.flow_id IS NOT NULL?
Do we need a new index for that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@norkans7 this is querying on tiny in memory tables created by the trigger - it's not hitting the real msg table

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay

@rowanseymour rowanseymour merged commit 0f1aaf7 into main Nov 22, 2024
5 checks passed
@rowanseymour rowanseymour deleted the flow_msg_counts branch November 22, 2024 14:49
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants