Commit 9615238
committed
perf(controlplane): denormalize organization_id onto workflow_runs
Makes org-scoped workflow run queries sargable via a new
(organization_id, created_at DESC) index, fixing the timeouts on the
workflow runs list reported in PFM-5839. The previous query joined to
workflows via a correlated EXISTS, which let the planner pick a
backward index scan on created_at and scan most of the table on orgs
with sparse recent activity.
A BEFORE INSERT trigger fills organization_id from the parent workflow
during the rolling-deploy window so old replicas that don't set the
column explicitly can keep writing. A follow-up release will drop the
trigger and function once every replica runs code that sets the
column directly.
Assisted-by: Claude Code
Signed-off-by: Miguel Martinez Trivino <miguel@chainloop.dev>
Chainloop-Trace-Sessions: f00cda5d-4707-40cf-800e-54da06ada0481 parent 5141752 commit 9615238
20 files changed
Lines changed: 952 additions & 55 deletions
File tree
- app/controlplane/pkg/data
- ent
- migrate
- migrations
- organization
- schema
- workflowrun
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 86 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
782 | 782 | | |
783 | 783 | | |
784 | 784 | | |
| 785 | + | |
785 | 786 | | |
786 | 787 | | |
787 | 788 | | |
| |||
793 | 794 | | |
794 | 795 | | |
795 | 796 | | |
796 | | - | |
| 797 | + | |
797 | 798 | | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
798 | 805 | | |
799 | 806 | | |
800 | 807 | | |
801 | 808 | | |
802 | 809 | | |
803 | | - | |
| 810 | + | |
804 | 811 | | |
805 | 812 | | |
806 | 813 | | |
807 | 814 | | |
808 | 815 | | |
809 | | - | |
| 816 | + | |
810 | 817 | | |
811 | 818 | | |
812 | 819 | | |
| |||
825 | 832 | | |
826 | 833 | | |
827 | 834 | | |
828 | | - | |
| 835 | + | |
829 | 836 | | |
830 | 837 | | |
831 | 838 | | |
| |||
835 | 842 | | |
836 | 843 | | |
837 | 844 | | |
838 | | - | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
839 | 856 | | |
840 | 857 | | |
841 | 858 | | |
| |||
860 | 877 | | |
861 | 878 | | |
862 | 879 | | |
863 | | - | |
| 880 | + | |
864 | 881 | | |
865 | 882 | | |
866 | 883 | | |
867 | 884 | | |
868 | | - | |
| 885 | + | |
869 | 886 | | |
870 | 887 | | |
871 | 888 | | |
| |||
1014 | 1031 | | |
1015 | 1032 | | |
1016 | 1033 | | |
1017 | | - | |
1018 | | - | |
1019 | | - | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
1020 | 1038 | | |
1021 | 1039 | | |
1022 | 1040 | | |
| |||
0 commit comments