60
60
FULL JOIN hangar_project h
61
61
ON LOWER (COALESCE(s .source_repository_host , m .source_repository_host )) = LOWER (h .source_repository_host )
62
62
AND LOWER (COALESCE(s .source_repository_owner , m .source_repository_owner )) = LOWER (h .source_repository_owner )
63
- AND LOWER (COALESCE(s .source_repository_name , m .source_repository_name )) = LOWER (h .source_repository_name );
63
+ AND LOWER (COALESCE(s .source_repository_name , m .source_repository_name )) = LOWER (h .source_repository_name );
64
+
65
+ -- Indexes
66
+
67
+ -- B-tree indexes for ordering by date_created
68
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_hangar_date_created_index
69
+ ON common_project (GREATEST(spigot_date_created, modrinth_date_created, hangar_date_created) DESC NULLS LAST);
70
+
71
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_date_created_index
72
+ ON common_project (GREATEST(spigot_date_created, modrinth_date_created, NULL ) DESC NULLS LAST);
73
+ CREATE INDEX IF NOT EXISTS common_project_spigot_hangar_date_created_index
74
+ ON common_project (GREATEST(spigot_date_created, NULL , hangar_date_created) DESC NULLS LAST);
75
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_hangar_date_created_index
76
+ ON common_project (GREATEST(NULL , modrinth_date_created, hangar_date_created) DESC NULLS LAST);
77
+
78
+ CREATE INDEX IF NOT EXISTS common_project_spigot_date_created_index
79
+ ON common_project (GREATEST(spigot_date_created, NULL , NULL ) DESC NULLS LAST);
80
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_date_created_index
81
+ ON common_project (GREATEST(NULL , modrinth_date_created, NULL ) DESC NULLS LAST);
82
+ CREATE INDEX IF NOT EXISTS common_project_hangar_date_created_index
83
+ ON common_project (GREATEST(NULL , NULL , hangar_date_created) DESC NULLS LAST);
84
+
85
+ -- B-tree indexes for ordering by date_updated
86
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_hangar_date_updated_index
87
+ ON common_project (GREATEST(spigot_date_updated, modrinth_date_updated, hangar_date_updated) DESC NULLS LAST);
88
+
89
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_date_updated_index
90
+ ON common_project (GREATEST(spigot_date_updated, modrinth_date_updated, NULL ) DESC NULLS LAST);
91
+ CREATE INDEX IF NOT EXISTS common_project_spigot_hangar_date_updated_index
92
+ ON common_project (GREATEST(spigot_date_updated, NULL , hangar_date_updated) DESC NULLS LAST);
93
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_hangar_date_updated_index
94
+ ON common_project (GREATEST(NULL , modrinth_date_updated, hangar_date_updated) DESC NULLS LAST);
95
+
96
+ CREATE INDEX IF NOT EXISTS common_project_spigot_date_updated_index
97
+ ON common_project (GREATEST(spigot_date_updated, NULL , NULL ) DESC NULLS LAST);
98
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_date_updated_index
99
+ ON common_project (GREATEST(NULL , modrinth_date_updated, NULL ) DESC NULLS LAST);
100
+ CREATE INDEX IF NOT EXISTS common_project_hangar_date_updated_index
101
+ ON common_project (GREATEST(NULL , NULL , hangar_date_updated) DESC NULLS LAST);
102
+
103
+ -- B-tree indexes for ordering by latest_minecraft_version
104
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_hangar_latest_minecraft_version_index
105
+ ON common_project (GREATEST(spigot_latest_minecraft_version, modrinth_latest_minecraft_version, hangar_latest_minecraft_version) DESC NULLS LAST);
106
+
107
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_latest_minecraft_version_index
108
+ ON common_project (GREATEST(spigot_latest_minecraft_version, modrinth_latest_minecraft_version, NULL ) DESC NULLS LAST);
109
+ CREATE INDEX IF NOT EXISTS common_project_spigot_hangar_latest_minecraft_version_index
110
+ ON common_project (GREATEST(spigot_latest_minecraft_version, NULL , hangar_latest_minecraft_version) DESC NULLS LAST);
111
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_hangar_latest_minecraft_version_index
112
+ ON common_project (GREATEST(NULL , modrinth_latest_minecraft_version, hangar_latest_minecraft_version) DESC NULLS LAST);
113
+
114
+ CREATE INDEX IF NOT EXISTS common_project_spigot_latest_minecraft_version_index
115
+ ON common_project (GREATEST(spigot_latest_minecraft_version, NULL , NULL ) DESC NULLS LAST);
116
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_latest_minecraft_version_index
117
+ ON common_project (GREATEST(NULL , modrinth_latest_minecraft_version, NULL ) DESC NULLS LAST);
118
+ CREATE INDEX IF NOT EXISTS common_project_hangar_latest_minecraft_version_index
119
+ ON common_project (GREATEST(NULL , NULL , hangar_latest_minecraft_version) DESC NULLS LAST);
120
+
121
+ -- B-tree indexes for ordering by downloads
122
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_hangar_downloads_index
123
+ ON common_project ((COALESCE(spigot_downloads, 0 ) + COALESCE(modrinth_downloads, 0 ) + COALESCE(hangar_downloads, 0 )) DESC NULLS LAST);
124
+
125
+ CREATE INDEX IF NOT EXISTS common_project_spigot_modrinth_downloads_index
126
+ ON common_project ((COALESCE(spigot_downloads, 0 ) + COALESCE(modrinth_downloads, 0 ) + 0 ) DESC NULLS LAST);
127
+ CREATE INDEX IF NOT EXISTS common_project_spigot_hangar_downloads_index
128
+ ON common_project ((COALESCE(spigot_downloads, 0 ) + 0 + COALESCE(hangar_downloads, 0 )) DESC NULLS LAST);
129
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_hangar_downloads_index
130
+ ON common_project ((0 + COALESCE(modrinth_downloads, 0 ) + COALESCE(hangar_downloads, 0 )) DESC NULLS LAST);
131
+
132
+ CREATE INDEX IF NOT EXISTS common_project_spigot_downloads_index
133
+ ON common_project ((COALESCE(spigot_downloads, 0 ) + 0 + 0 ) DESC NULLS LAST);
134
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_downloads_index
135
+ ON common_project ((0 + COALESCE(modrinth_downloads, 0 ) + 0 ) DESC NULLS LAST);
136
+ CREATE INDEX IF NOT EXISTS common_project_hangar_downloads_index
137
+ ON common_project ((0 + 0 + COALESCE(hangar_downloads, 0 )) DESC NULLS LAST);
138
+
139
+ -- B-tree indexes for ordering by likes and stars
140
+ CREATE INDEX IF NOT EXISTS common_project_spigot_hangar_likes_and_stars_index
141
+ ON common_project ((COALESCE(spigot_likes, 0 ) + COALESCE(hangar_stars, 0 )) DESC NULLS LAST);
142
+
143
+ CREATE INDEX IF NOT EXISTS common_project_spigot_likes_index
144
+ ON common_project ((COALESCE(spigot_likes, 0 ) + 0 ) DESC NULLS LAST);
145
+ CREATE INDEX IF NOT EXISTS common_project_hangar_stars_index
146
+ ON common_project ((0 + COALESCE(hangar_stars, 0 )) DESC NULLS LAST);
147
+
148
+ -- B-tree indexes for ordering by follows and watchers
149
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_hangar_follows_and_watchers_index
150
+ ON common_project ((COALESCE(modrinth_follows, 0 ) + COALESCE(hangar_watchers, 0 )) DESC NULLS LAST);
151
+
152
+ CREATE INDEX IF NOT EXISTS common_project_modrinth_follows_index
153
+ ON common_project ((COALESCE(modrinth_follows, 0 ) + 0 ) DESC NULLS LAST);
154
+ CREATE INDEX IF NOT EXISTS common_project_hangar_watchers_index
155
+ ON common_project ((0 + COALESCE(hangar_watchers, 0 )) DESC NULLS LAST);
156
+
157
+ -- Trigram indexes for text search on name, description, and author
158
+ CREATE INDEX IF NOT EXISTS common_project_name_index
159
+ ON common_project
160
+ USING gin (spigot_name gin_trgm_ops, modrinth_name gin_trgm_ops, hangar_name gin_trgm_ops);
161
+
162
+ CREATE INDEX IF NOT EXISTS common_project_description_index
163
+ ON common_project
164
+ USING gin (spigot_description gin_trgm_ops, modrinth_description gin_trgm_ops, hangar_description gin_trgm_ops);
165
+
166
+ CREATE INDEX IF NOT EXISTS common_project_author_index
167
+ ON common_project
168
+ USING gin (spigot_author gin_trgm_ops, modrinth_author gin_trgm_ops, hangar_author gin_trgm_ops);
0 commit comments