Skip to content

Conversation

@MilanPospisil
Copy link
Contributor

@MilanPospisil MilanPospisil commented Nov 24, 2025

[AAP-59250]

Speedup for main_jobevent_service and main_jobevent in library using LATERAL.

main_jobevent service now reduces number of pairs in jobs:

where_clause = f'(e.job_id, e.job_created) IN (VALUES {pairs_sql})'

This will contain all jobs finished in since-until, which can be tens of thousands of jobs!

This can easily bloat. We introduce new approach. Since we can not join on jobs according to job_created, because in order to work with partitions prunning on job_created (job_created is houlrly partition in event table), we need to do very clear literal explicit filter on event table (thus WHERE with contstant job_created).

Improvements:
job_created is simplified - awx uses hourly partitions, so we split into hourly job_created and put it into set, this keeps max hundreds of hours

Then we also makes groups of nearby hours to reduce it even more, for example 2025-06-01 10:00:00 and 2025-06-01 11:00:00 will be concatenated and the resulted range filter will be job_created => min AND job_created < max.

Also removed cyclic import.

@MilanPospisil MilanPospisil marked this pull request as ready for review November 25, 2025 07:50
@MilanPospisil MilanPospisil marked this pull request as draft November 25, 2025 07:56
@MilanPospisil MilanPospisil marked this pull request as ready for review November 25, 2025 11:12
@MilanPospisil MilanPospisil force-pushed the milan_optimize_queries2 branch from 88b699b to 5abd68f Compare November 25, 2025 11:22
@MilanPospisil MilanPospisil marked this pull request as draft November 25, 2025 11:25
@MilanPospisil MilanPospisil marked this pull request as ready for review November 25, 2025 13:17
@MilanPospisil MilanPospisil marked this pull request as draft November 25, 2025 14:05
@MilanPospisil MilanPospisil force-pushed the milan_optimize_queries2 branch from 42a2621 to 2a2f927 Compare November 25, 2025 14:24
@sonarqubecloud
Copy link

@MilanPospisil MilanPospisil marked this pull request as ready for review November 26, 2025 07:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants