Go to file
Yorick Peterse 70985aa19b
Limit the number of pipelines to count
When displaying the project pipelines dashboard we display a few tabs
for different pipeline states. For every such tab we count the number of
pipelines that belong to it. For large projects such as GitLab CE this
means having to count over 80 000 rows, which can easily take between 70
and 100 milliseconds per query.

To improve this we apply a technique we already use for search results:
we limit the number of rows to count. The current limit is 1000, which
means that if more than 1000 rows are present for a state we will show
"1000+" instead of the exact number. The SQL queries used for this
perform much better than a regular COUNT, even when a project has a lot
of pipelines.

Prior to these changes we would end up running a query like this:

    SELECT COUNT(*)
    FROM ci_pipelines
    WHERE project_id = 13083
    AND status IN ('success', 'failed', 'canceled')

This would produce a plan along the lines of the following:

    Aggregate  (cost=3147.55..3147.56 rows=1 width=8) (actual time=501.413..501.413 rows=1 loops=1)
      Buffers: shared hit=17116 read=861 dirtied=2
      ->  Index Only Scan using index_ci_pipelines_on_project_id_and_ref_and_status_and_id on ci_pipelines  (cost=0.56..2984.14 rows=65364 width=0) (actual time=0.095..490.263 rows=80388 loops=1)
            Index Cond: (project_id = 13083)
            Filter: ((status)::text = ANY ('{success,failed,canceled}'::text[]))
            Rows Removed by Filter: 2894
            Heap Fetches: 353
            Buffers: shared hit=17116 read=861 dirtied=2
    Planning time: 1.409 ms
    Execution time: 501.519 ms

Using the LIMIT count technique we instead run the following query:

    SELECT COUNT(*)
    FROM (
        SELECT 1
        FROM ci_pipelines
        WHERE project_id = 13083
        AND status IN ('success', 'failed', 'canceled')
        LIMIT 1001
    ) for_count

This query produces the following plan:

    Aggregate  (cost=58.77..58.78 rows=1 width=8) (actual time=1.726..1.727 rows=1 loops=1)
      Buffers: shared hit=169 read=15
      ->  Limit  (cost=0.56..46.25 rows=1001 width=4) (actual time=0.164..1.570 rows=1001 loops=1)
            Buffers: shared hit=169 read=15
            ->  Index Only Scan using index_ci_pipelines_on_project_id_and_ref_and_status_and_id on ci_pipelines  (cost=0.56..2984.14 rows=65364 width=4) (actual time=0.162..1.426 rows=1001 loops=1)
                  Index Cond: (project_id = 13083)
                  Filter: ((status)::text = ANY ('{success,failed,canceled}'::text[]))
                  Rows Removed by Filter: 9
                  Heap Fetches: 10
                  Buffers: shared hit=169 read=15
    Planning time: 1.832 ms
    Execution time: 1.821 ms

While this query still uses a Filter for the "status" field the number
of rows that it may end up filtering (at most 1001) is small enough that
an additional index does not appear to be necessary at this time.

See https://gitlab.com/gitlab-org/gitlab-ce/issues/43132#note_68659234
for more information.
2018-05-17 13:52:59 +02:00
.github
.gitlab Improve the squash step in the 'Database Changes' MR template 2018-05-15 10:55:47 +02:00
app Limit the number of pipelines to count 2018-05-17 13:52:59 +02:00
bin Merge branch 'blackst0ne-remove-spinach' into 'master' 2018-05-15 09:43:55 +00:00
builds
changelogs Resolve "Opening Project with invite but without accepting leads to 404 error page" 2018-05-17 09:19:47 +00:00
config More verbose logging for deprecated path access 2018-05-14 15:08:51 +02:00
db Add a unique and not null constraint on the project_features.project_id column 2018-05-15 14:20:14 +02:00
doc Merge branch 'docs-fe-vuex-updates' into 'master' 2018-05-16 08:40:40 +00:00
docker Common Docker Documentation Location in `gitlab-ce` 2017-08-25 19:23:49 +00:00
fixtures/emojis Move :gay_pride_flag: to flags category 2017-11-15 07:36:19 -06:00
generator_templates Run plugins as separate process and pass data via STDIN 2018-02-26 16:06:49 +02:00
lib Merge branch 'zj-workhorse-commit-patch-diff' into 'master' 2018-05-17 08:12:33 +00:00
locale Project Sidebar: Split CI/CD into CI/CD and Operations 2018-05-16 11:16:33 +00:00
log
plugins/examples Reorganize plugins dir structure 2018-02-26 16:06:49 +02:00
public Add the /help page in robots.txt 2018-03-22 10:55:02 +01:00
qa Succeed or fail fast based on job status first 2018-05-08 11:56:43 -07:00
rubocop Introduce spec/fast_spec_helper.rb to run spec files that don't rely on the whole Rails env 2018-04-23 12:20:30 +02:00
scripts Grant privileges after database is created 2018-05-16 21:52:08 +08:00
shared
spec Limit the number of pipelines to count 2018-05-17 13:52:59 +02:00
symbol Resolve "Better SVG Usage in the Frontend" 2017-09-22 08:39:47 +00:00
tmp
vendor Changes Ingress RBAC value to be false as default 2018-05-14 10:27:24 -05:00
.babelrc only apply rewire plugin when running karma tests 2018-04-23 00:54:21 -05:00
.codeclimate.yml Don't run RuboCop nor ESLint checks in the codequality job as this is already done by the static-analysis job 2018-04-04 17:27:32 +02:00
.csscomb.json
.eslintignore update eslintignore for node scripts 2018-03-23 11:53:12 -05:00
.eslintrc Prettier Phase 1: Prettier Configuration, Prettifying of files and documentation 2018-03-14 19:32:36 +00:00
.flayignore Fix bunch of texts 2018-04-06 04:41:45 +09:00
.foreman
.gitignore Ignore knapsack and rspec_flaky 2018-05-04 20:51:03 +08:00
.gitlab-ci.yml Grant privileges after database is created 2018-05-16 21:52:08 +08:00
.haml-lint.yml Add custom linter for inline JavaScript to haml_lint (!9742) 2017-08-07 11:37:16 +02:00
.mailmap
.nvmrc Update .nvmrc to current stable (v9.0.0) 2017-11-02 13:15:39 +01:00
.pkgr.yml
.prettierignore ensure stylesheets are included as well, make prettierrc even more inclusive 2018-03-23 12:56:57 -05:00
.prettierrc ensure stylesheets are included as well, make prettierrc even more inclusive 2018-03-23 12:56:57 -05:00
.rubocop.yml Merge branch 'fj-15329-services-callbacks-ssrf' into 'security-10-6' 2018-03-21 14:39:21 +00:00
.rubocop_todo.yml Move spec helpers/matchers/shared examples/contexts to their relevant folder 2018-04-23 12:20:30 +02:00
.ruby-version Bump .ruby-version from 2.3.6 to 2.3.7 2018-04-09 06:47:08 -07:00
.scss-lint.yml Web IDE blob image + default fallback 2018-04-06 17:49:06 +00:00
CHANGELOG.md Update CHANGELOG.md for 10.7.3 2018-05-02 16:36:13 -05:00
CONTRIBUTING.md Merge branch 'simplify-priority' into 'master' 2018-05-15 14:45:39 +00:00
GITALY_SERVER_VERSION Fix finding wiki pages when they have invalidly-encoded content 2018-05-09 18:03:03 +02:00
GITLAB_PAGES_VERSION Use GitLab Pages v0.9.1 2018-04-30 11:39:02 +01:00
GITLAB_SHELL_VERSION Use gitlab-shell 7.1.2 2018-04-09 15:28:46 +02:00
GITLAB_WORKHORSE_VERSION Use gitlab-workhorse 4.2.0 2018-05-01 15:04:10 +02:00
Gemfile Merge branch 'blackst0ne-remove-spinach' into 'master' 2018-05-15 09:43:55 +00:00
Gemfile.lock Merge branch 'blackst0ne-remove-spinach' into 'master' 2018-05-15 09:43:55 +00:00
Gemfile.rails5 [Rails5] Add Gemfile.rails5 2018-03-15 09:50:16 +11:00
Gemfile.rails5.lock Update Gemfile.rails5.lock 2018-05-14 18:56:38 +11:00
LICENSE edit GitLab license info in regards to CC licensing 2018-05-15 15:04:48 -07:00
MAINTENANCE.md Change location of the maintenance policy document. Add version support information. [CI skip] 2017-10-11 15:01:55 +02:00
PROCESS.md Clarify that the Pick Into X.Y label is added after approval 2018-03-08 10:29:53 +00:00
Procfile Launch mail_room manually and remove foreman reference 2018-03-21 11:52:05 -05:00
README.md edit GitLab license info in regards to CC licensing 2018-05-15 15:04:48 -07:00
Rakefile
VERSION Update VERSION to 10.8.0-pre 2018-04-20 11:08:55 +02:00
config.ru Increase the memory limits used in the unicorn killer 2018-03-22 17:21:10 -07:00
doc_styleguide.md
docker-compose.yml
package.json Correct skewed Kubernetes popover illustration 2018-05-14 17:58:36 +00:00
yarn.lock Correct skewed Kubernetes popover illustration 2018-05-14 17:58:36 +00:00

README.md

GitLab

Build status Overall test coverage Dependency Status Code Climate Core Infrastructure Initiative Best Practices Gitter

Test coverage

  • Ruby coverage Ruby
  • JavaScript coverage JavaScript

Canonical source

The canonical source of GitLab Community Edition is hosted on GitLab.com.

Open source software to collaborate on code

To see how GitLab looks please see the features page on our website.

  • Manage Git repositories with fine grained access controls that keep your code secure
  • Perform code reviews and enhance collaboration with merge requests
  • Complete continuous integration (CI) and CD pipelines to builds, test, and deploy your applications
  • Each project can also have an issue tracker, issue board, and a wiki
  • Used by more than 100,000 organizations, GitLab is the most popular solution to manage Git repositories on-premises
  • Completely free and open source (MIT Expat license)

Hiring

We're hiring developers, support people, and production engineers all the time, please see our jobs page.

Editions

There are two editions of GitLab:

  • GitLab Community Edition (CE) is available freely under the MIT Expat license.
  • GitLab Enterprise Edition (EE) includes extra features that are more useful for organizations with more than 100 users. To use EE and get official support please become a subscriber.

Website

On about.gitlab.com you can find more information about:

Requirements

Please see the requirements documentation for system requirements and more information about the supported operating systems.

Installation

The recommended way to install GitLab is with the Omnibus packages on our package server. Compared to an installation from source, this is faster and less error prone. Just select your operating system, download the respective package (Debian or RPM) and install it using the system's package manager.

There are various other options to install GitLab, please refer to the installation page on the GitLab website for more information.

You can access a new installation with the login root and password 5iveL!fe, after login you are required to set a unique password.

Contributing

GitLab is an open source project and we are very happy to accept community contributions. Please refer to CONTRIBUTING.md for details.

Licensing

GitLab Community Edition (CE) is available freely under the MIT Expat license.

All third party components incorporated into the GitLab Software are licensed under the original license provided by the owner of the applicable component.

All Documentation content that resides under the doc/ directory of this repository is licensed under Creative Commons: CC BY-SA 4.0.

Install a development environment

To work on GitLab itself, we recommend setting up your development environment with the GitLab Development Kit. If you do not use the GitLab Development Kit you need to install and setup all the dependencies yourself, this is a lot of work and error prone. One small thing you also have to do when installing it yourself is to copy the example development unicorn configuration file:

cp config/unicorn.rb.example.development config/unicorn.rb

Instructions on how to start GitLab and how to run the tests can be found in the getting started section of the GitLab Development Kit.

Software stack

GitLab is a Ruby on Rails application that runs on the following software:

  • Ubuntu/Debian/CentOS/RHEL/OpenSUSE
  • Ruby (MRI) 2.3
  • Git 2.8.4+
  • Redis 2.8+
  • PostgreSQL (preferred) or MySQL

For more information please see the architecture documentation.

UX design

Please adhere to the UX Guide when creating designs and implementing code.

Third-party applications

There are a lot of third-party applications integrating with GitLab. These include GUI Git clients, mobile applications and API wrappers for various languages.

GitLab release cycle

For more information about the release process see the release documentation.

Upgrading

For upgrading information please see our update page.

Documentation

All documentation can be found on docs.gitlab.com/ce/.

Getting help

Please see Getting help for GitLab on our website for the many options to get help.

Is it any good?

Yes

Is it awesome?

Thanks for asking this question Joshua. These people seem to like it.