Commit 1cbbf0f9 authored by Russell Dickenson's avatar Russell Dickenson

Merge branch '233085-add-batch_size-parameter-to-telemetry-docs' into 'master'

Add batch_size parameter to Telemetry docs

Closes #233085

See merge request gitlab-org/gitlab!38376
parents 03de62c2 ded72317
...@@ -155,7 +155,7 @@ There are two batch counting methods provided, `Ordinary Batch Counters` and `Di ...@@ -155,7 +155,7 @@ There are two batch counting methods provided, `Ordinary Batch Counters` and `Di
Handles `ActiveRecord::StatementInvalid` error Handles `ActiveRecord::StatementInvalid` error
Simple count of a given ActiveRecord_Relation Simple count of a given ActiveRecord_Relation, does a non-distinct batch count, smartly reduces batch_size and handles errors.
Method: `count(relation, column = nil, batch: true, start: nil, finish: nil)` Method: `count(relation, column = nil, batch: true, start: nil, finish: nil)`
...@@ -179,15 +179,16 @@ count(::Clusters::Cluster.aws_installed.enabled, :cluster_id, start: ::Clusters: ...@@ -179,15 +179,16 @@ count(::Clusters::Cluster.aws_installed.enabled, :cluster_id, start: ::Clusters:
Handles `ActiveRecord::StatementInvalid` error Handles `ActiveRecord::StatementInvalid` error
Distinct count of a given ActiveRecord_Relation on given column Distinct count of a given ActiveRecord_Relation on given column, a distinct batch count, smartly reduces batch_size and handles errors.
Method: `distinct_count(relation, column = nil, batch: true, start: nil, finish: nil)` Method: `distinct_count(relation, column = nil, batch: true, batch_size: nil, start: nil, finish: nil)`
Arguments: Arguments:
- `relation` the ActiveRecord_Relation to perform the count - `relation` the ActiveRecord_Relation to perform the count
- `column` the column to perform the distinct count, by default is the primary key - `column` the column to perform the distinct count, by default is the primary key
- `batch`: default `true` in order to use batch counting - `batch`: default `true` in order to use batch counting
- `batch_size`: if none set it will use default value 10000 from `Gitlab::Database::BatchCounter`
- `start`: custom start of the batch counting in order to avoid complex min calculations - `start`: custom start of the batch counting in order to avoid complex min calculations
- `end`: custom end of the batch counting in order to avoid complex min calculations - `end`: custom end of the batch counting in order to avoid complex min calculations
...@@ -318,6 +319,7 @@ We also use `#database-lab` and [explain.depesz.com](https://explain.depesz.com/ ...@@ -318,6 +319,7 @@ We also use `#database-lab` and [explain.depesz.com](https://explain.depesz.com/
- Use specialized indexes [example 1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26871), [example 2](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26445). - Use specialized indexes [example 1](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26871), [example 2](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/26445).
- Use defined `start` and `finish`, and simple queries, because these values can be memoized and reused, [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37155). - Use defined `start` and `finish`, and simple queries, because these values can be memoized and reused, [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/37155).
- Avoid joins and write the queries as simply as possible, [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36316). - Avoid joins and write the queries as simply as possible, [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/36316).
- Set a custom `batch_size` for `distinct_count`, [example](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/38000).
### 4. Add the metric definition ### 4. Add the metric definition
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment