Unable to delete old builds from GILAB CI

Hi All,

we are using GITLAB Ci Runner and we have total of 12000 builds on the same runner, can any one let us know the command to delete the old builds.

I had the same issue with 12.6k builds in some project.

Found out gitlab’s doing something like:

select * from builds where project_id = 1 and sha = '....';

Just add an index to the table:

alter table builds add key (`project_id`, `sha`);

It took around 11 minutes to add the key. But the pages load almost instantly now.

gitlab-ci is also adding the build output into the builds table…so it was essentially loading every row and every blob for that project and then picking 1+ rows out of it.