[{"data":1,"prerenderedAt":2210},["ShallowReactive",2],{"/blog/database-case-study-store-and-update-namespace-statistics":3,"navigation-en-us":1457,"banner-en-us":1895,"footer-en-us":1903,"blog-post-authors-en-us-Mayra Cabrera":2150,"blog-related-posts-en-us-database-case-study-store-and-update-namespace-statistics":2165,"blog-share-wrapper-en-us":2190,"next-steps-en-us":2200},{"id":4,"title":5,"authors":6,"body":8,"category":1437,"date":1438,"description":1439,"extension":1440,"externalUrl":1441,"faq":1441,"featured":1442,"heroImage":1443,"hidePromo":1442,"meta":1444,"navigation":1445,"path":1446,"seo":1447,"slug":1451,"stem":1452,"tags":1453,"template":1455,"updatedDate":1441,"__hash__":1456},"blogPosts/en-us/blog/database-case-study-store-and-update-namespace-statistics.md","Store and update namespace statistics in a performant manner",[7],"Mayra Cabrera",{"type":9,"value":10,"toc":1421},"minimark",[11,15,25,30,40,43,46,79,82,103,112,119,123,128,137,463,466,475,478,493,497,505,957,960,964,979,982,986,989,1039,1042,1108,1111,1129,1133,1136,1219,1222,1238,1241,1263,1271,1275,1284,1299,1302,1306,1315,1319,1322,1329,1333,1339,1345,1351,1354,1360,1366,1370,1377,1380,1403,1417],[12,13,14],"p",{},"Managing storage space on large GitLab instances, such as GitLab.com, can be a challenge. At the moment, we only have a restriction on repository limits, but no restriction on most of the other items that can consume storage space: wiki, lfs objects, artifacts, and packages, to mention a few.",[12,16,17,18,24],{},"We want to facilitate a method for easily viewing the amount of storage consumed by a group and allow easy management on GitLab.com by setting ",[19,20,23],"a",{"href":21,"rel":22},"https://gitlab.com/groups/gitlab-org/-/epics/886",[],"storage and limits management for groups",". But to do that we need a way to track the statistics of a namespace, whether it is a Group or a User namespace.",[26,27,29],"h2",{"id":28},"proposal-to-track-the-statistics-of-a-namespace","Proposal to track the statistics of a namespace",[31,32,33,37],"ol",{},[34,35,36],"li",{},"Create a new ActiveRecord model to hold the namespaces' statistics in an aggregated form: Only for root namespaces.",[34,38,39],{},"Refresh the statistics in this model every time a project belonging to this namespace is changed.",[12,41,42],{},"The \"refresh\" part is the tricky one. Currently we don't have a pattern to update/refresh the namespace statistics every time a project belonging to the namespace is updated.",[12,44,45],{},"We refreshed projects statistics in the following way:",[31,47,48,56,68],{},[34,49,50,51,55],{},"We have a model called ",[52,53,54],"code",{},"ProjectStatistics",",",[34,57,58,59,61,62,67],{},"The records on ",[52,60,54],{}," are updated through a ",[19,63,66],{"href":64,"rel":65},"https://gitlab.com/gitlab-org/gitlab-ce/blob/v12.2.0.pre/app/models/project.rb#L90",[],"callback"," every time the project is saved.",[34,69,70,71,78],{},"The summary of those statistics per namespace is then retrieved by ",[19,72,75],{"href":73,"rel":74},"https://gitlab.com/gitlab-org/gitlab-ce/blob/v12.2.0.pre/app/models/namespace.rb#L70",[],[52,76,77],{},"Namespaces#with_statistics"," scope.",[12,80,81],{},"Analyzing this query we noticed that:",[83,84,85,96],"ul",{},[34,86,87,88,91,92,95],{},"It takes up to ",[52,89,90],{},"1.2"," seconds for namespaces with over ",[52,93,94],{},"15 000"," projects.",[34,97,98,99,102],{},"Any attempt to run ",[52,100,101],{},"EXPLAIN ANALYZE"," results in query timeouts (15 seconds) when using our internal tooling.",[12,104,105,106,111],{},"Additionally, the callback to update the project statistics doesn't scale. It is currently one of the most ",[19,107,110],{"href":108,"rel":109},"https://gitlab.com/gitlab-org/gitlab-ce/issues/62488",[],"frequently run and expensive database queries"," on GitLab.com. We can't add one more query to it as\nit will increase the transaction's length.",[12,113,114,115,118],{},"Because of these reasons, we can't apply the same pattern to store\nand update the namespaces' statistics, as the ",[52,116,117],{},"namespaces"," table is one\nof the largest tables on GitLab.com. Therefore, we have to find a performant and\nalternative method.",[26,120,122],{"id":121},"our-attempts","Our Attempts",[124,125,127],"h3",{"id":126},"attempt-a-postgresql-materialized-view","Attempt A: PostgreSQL materialized view",[12,129,130,131,136],{},"Update the ActiveRecord model with a refresh strategy based on project routes and a ",[19,132,135],{"href":133,"rel":134},"https://www.postgresql.org/docs/9.6/rules-materializedviews.html",[],"materialized view",":",[138,139,144],"pre",{"className":140,"code":141,"language":142,"meta":143,"style":143},"language-sql shiki shiki-themes github-light","SELECT split_part(\"rs\".path, '/', 1) as root_path,\n        COALESCE(SUM(ps.storage_size), 0) AS storage_size,\n        COALESCE(SUM(ps.repository_size), 0) AS repository_size,\n        COALESCE(SUM(ps.wiki_size), 0) AS wiki_size,\n        COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size,\n        COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size,\n        COALESCE(SUM(ps.packages_size), 0) AS packages_size\nFROM \"projects\"\n    INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'\n    INNER JOIN project_statistics ps ON ps.project_id  = projects.id\nGROUP BY root_path\n","sql","",[52,145,146,190,226,255,284,313,342,371,380,426,454],{"__ignoreMap":143},[147,148,151,155,159,163,166,169,172,175,177,181,184,187],"span",{"class":149,"line":150},"line",1,[147,152,154],{"class":153},"sD7c4","SELECT",[147,156,158],{"class":157},"sgsFI"," split_part(",[147,160,162],{"class":161},"sYBdl","\"rs\"",[147,164,165],{"class":157},".",[147,167,168],{"class":153},"path",[147,170,171],{"class":157},", ",[147,173,174],{"class":161},"'/'",[147,176,171],{"class":157},[147,178,180],{"class":179},"sYu0t","1",[147,182,183],{"class":157},") ",[147,185,186],{"class":153},"as",[147,188,189],{"class":157}," root_path,\n",[147,191,193,196,199,202,204,207,209,212,215,218,220,223],{"class":149,"line":192},2,[147,194,195],{"class":179},"        COALESCE",[147,197,198],{"class":157},"(",[147,200,201],{"class":179},"SUM",[147,203,198],{"class":157},[147,205,206],{"class":179},"ps",[147,208,165],{"class":157},[147,210,211],{"class":179},"storage_size",[147,213,214],{"class":157},"), ",[147,216,217],{"class":179},"0",[147,219,183],{"class":157},[147,221,222],{"class":153},"AS",[147,224,225],{"class":157}," storage_size,\n",[147,227,229,231,233,235,237,239,241,244,246,248,250,252],{"class":149,"line":228},3,[147,230,195],{"class":179},[147,232,198],{"class":157},[147,234,201],{"class":179},[147,236,198],{"class":157},[147,238,206],{"class":179},[147,240,165],{"class":157},[147,242,243],{"class":179},"repository_size",[147,245,214],{"class":157},[147,247,217],{"class":179},[147,249,183],{"class":157},[147,251,222],{"class":153},[147,253,254],{"class":157}," repository_size,\n",[147,256,258,260,262,264,266,268,270,273,275,277,279,281],{"class":149,"line":257},4,[147,259,195],{"class":179},[147,261,198],{"class":157},[147,263,201],{"class":179},[147,265,198],{"class":157},[147,267,206],{"class":179},[147,269,165],{"class":157},[147,271,272],{"class":179},"wiki_size",[147,274,214],{"class":157},[147,276,217],{"class":179},[147,278,183],{"class":157},[147,280,222],{"class":153},[147,282,283],{"class":157}," wiki_size,\n",[147,285,287,289,291,293,295,297,299,302,304,306,308,310],{"class":149,"line":286},5,[147,288,195],{"class":179},[147,290,198],{"class":157},[147,292,201],{"class":179},[147,294,198],{"class":157},[147,296,206],{"class":179},[147,298,165],{"class":157},[147,300,301],{"class":179},"lfs_objects_size",[147,303,214],{"class":157},[147,305,217],{"class":179},[147,307,183],{"class":157},[147,309,222],{"class":153},[147,311,312],{"class":157}," lfs_objects_size,\n",[147,314,316,318,320,322,324,326,328,331,333,335,337,339],{"class":149,"line":315},6,[147,317,195],{"class":179},[147,319,198],{"class":157},[147,321,201],{"class":179},[147,323,198],{"class":157},[147,325,206],{"class":179},[147,327,165],{"class":157},[147,329,330],{"class":179},"build_artifacts_size",[147,332,214],{"class":157},[147,334,217],{"class":179},[147,336,183],{"class":157},[147,338,222],{"class":153},[147,340,341],{"class":157}," build_artifacts_size,\n",[147,343,345,347,349,351,353,355,357,360,362,364,366,368],{"class":149,"line":344},7,[147,346,195],{"class":179},[147,348,198],{"class":157},[147,350,201],{"class":179},[147,352,198],{"class":157},[147,354,206],{"class":179},[147,356,165],{"class":157},[147,358,359],{"class":179},"packages_size",[147,361,214],{"class":157},[147,363,217],{"class":179},[147,365,183],{"class":157},[147,367,222],{"class":153},[147,369,370],{"class":157}," packages_size\n",[147,372,374,377],{"class":149,"line":373},8,[147,375,376],{"class":153},"FROM",[147,378,379],{"class":161}," \"projects\"\n",[147,381,383,386,389,392,395,397,400,403,406,408,411,414,416,418,421,423],{"class":149,"line":382},9,[147,384,385],{"class":153},"    INNER JOIN",[147,387,388],{"class":157}," routes rs ",[147,390,391],{"class":153},"ON",[147,393,394],{"class":179}," rs",[147,396,165],{"class":157},[147,398,399],{"class":179},"source_id",[147,401,402],{"class":153}," =",[147,404,405],{"class":179}," projects",[147,407,165],{"class":157},[147,409,410],{"class":179},"id",[147,412,413],{"class":153}," AND",[147,415,394],{"class":179},[147,417,165],{"class":157},[147,419,420],{"class":179},"source_type",[147,422,402],{"class":153},[147,424,425],{"class":161}," 'Project'\n",[147,427,429,431,434,436,439,441,444,447,449,451],{"class":149,"line":428},10,[147,430,385],{"class":153},[147,432,433],{"class":157}," project_statistics ps ",[147,435,391],{"class":153},[147,437,438],{"class":179}," ps",[147,440,165],{"class":157},[147,442,443],{"class":179},"project_id",[147,445,446],{"class":153},"  =",[147,448,405],{"class":179},[147,450,165],{"class":157},[147,452,453],{"class":179},"id\n",[147,455,457,460],{"class":149,"line":456},11,[147,458,459],{"class":153},"GROUP BY",[147,461,462],{"class":157}," root_path\n",[12,464,465],{},"We could then execute the query with:",[138,467,469],{"className":140,"code":468,"language":142,"meta":143,"style":143},"REFRESH MATERIALIZED VIEW root_namespace_storage_statistics;\n",[52,470,471],{"__ignoreMap":143},[147,472,473],{"class":149,"line":150},[147,474,468],{"class":157},[12,476,477],{},"While this implied a single query update, it has some downsides:",[83,479,480,483,490],{},[34,481,482],{},"The query itself would not be fast, as it would need to update all the statistics every time it runs. Execution time of this query will increase as the number of namespaces and projects grow.",[34,484,485,486,165],{},"Materialized views syntax varies from PostgreSQL and MySQL. At the time this feature was worked on, ",[19,487,489],{"href":488},"/blog/removing-mysql-support/","GitLab still supported MySQL, which it now no longer supports.",[34,491,492],{},"Rails does not have native support for materialized views. We'd need to use a specialized gem to take care of the management of the database views, which implies additional work.",[124,494,496],{"id":495},"attempt-b-an-update-through-a-cte","Attempt B: An update through a CTE",[12,498,499,500,165],{},"Update the ActiveRecord model with a refresh strategy through a ",[19,501,504],{"href":502,"rel":503},"https://www.postgresql.org/docs/9.1/queries-with.html",[],"Common Table Expression",[138,506,508],{"className":140,"code":507,"language":142,"meta":143,"style":143},"WITH refresh AS (\n  SELECT split_part(\"rs\".path, '/', 1) as root_path,\n        COALESCE(SUM(ps.storage_size), 0) AS storage_size,\n        COALESCE(SUM(ps.repository_size), 0) AS repository_size,\n        COALESCE(SUM(ps.wiki_size), 0) AS wiki_size,\n        COALESCE(SUM(ps.lfs_objects_size), 0) AS lfs_objects_size,\n        COALESCE(SUM(ps.build_artifacts_size), 0) AS build_artifacts_size,\n        COALESCE(SUM(ps.packages_size), 0) AS packages_size\n  FROM \"projects\"\n        INNER JOIN routes rs ON rs.source_id = projects.id AND rs.source_type = 'Project'\n        INNER JOIN project_statistics ps ON ps.project_id  = projects.id\n  GROUP BY root_path)\nUPDATE namespace_storage_statistics\nSET storage_size = refresh.storage_size,\n    repository_size = refresh.repository_size,\n    wiki_size = refresh.wiki_size,\n    lfs_objects_size = refresh.lfs_objects_size,\n    build_artifacts_size = refresh.build_artifacts_size,\n    packages_size  = refresh.packages_size\nFROM refresh\n    INNER JOIN routes rs ON rs.path = refresh.root_path AND rs.source_type = 'Namespace'\nWHERE namespace_storage_statistics.namespace_id = rs.source_id\n",[52,509,510,523,550,576,602,628,654,680,706,713,748,770,779,788,810,826,842,858,874,889,897,934],{"__ignoreMap":143},[147,511,512,515,518,520],{"class":149,"line":150},[147,513,514],{"class":153},"WITH",[147,516,517],{"class":157}," refresh ",[147,519,222],{"class":153},[147,521,522],{"class":157}," (\n",[147,524,525,528,530,532,534,536,538,540,542,544,546,548],{"class":149,"line":192},[147,526,527],{"class":153},"  SELECT",[147,529,158],{"class":157},[147,531,162],{"class":161},[147,533,165],{"class":157},[147,535,168],{"class":153},[147,537,171],{"class":157},[147,539,174],{"class":161},[147,541,171],{"class":157},[147,543,180],{"class":179},[147,545,183],{"class":157},[147,547,186],{"class":153},[147,549,189],{"class":157},[147,551,552,554,556,558,560,562,564,566,568,570,572,574],{"class":149,"line":228},[147,553,195],{"class":179},[147,555,198],{"class":157},[147,557,201],{"class":179},[147,559,198],{"class":157},[147,561,206],{"class":179},[147,563,165],{"class":157},[147,565,211],{"class":179},[147,567,214],{"class":157},[147,569,217],{"class":179},[147,571,183],{"class":157},[147,573,222],{"class":153},[147,575,225],{"class":157},[147,577,578,580,582,584,586,588,590,592,594,596,598,600],{"class":149,"line":257},[147,579,195],{"class":179},[147,581,198],{"class":157},[147,583,201],{"class":179},[147,585,198],{"class":157},[147,587,206],{"class":179},[147,589,165],{"class":157},[147,591,243],{"class":179},[147,593,214],{"class":157},[147,595,217],{"class":179},[147,597,183],{"class":157},[147,599,222],{"class":153},[147,601,254],{"class":157},[147,603,604,606,608,610,612,614,616,618,620,622,624,626],{"class":149,"line":286},[147,605,195],{"class":179},[147,607,198],{"class":157},[147,609,201],{"class":179},[147,611,198],{"class":157},[147,613,206],{"class":179},[147,615,165],{"class":157},[147,617,272],{"class":179},[147,619,214],{"class":157},[147,621,217],{"class":179},[147,623,183],{"class":157},[147,625,222],{"class":153},[147,627,283],{"class":157},[147,629,630,632,634,636,638,640,642,644,646,648,650,652],{"class":149,"line":315},[147,631,195],{"class":179},[147,633,198],{"class":157},[147,635,201],{"class":179},[147,637,198],{"class":157},[147,639,206],{"class":179},[147,641,165],{"class":157},[147,643,301],{"class":179},[147,645,214],{"class":157},[147,647,217],{"class":179},[147,649,183],{"class":157},[147,651,222],{"class":153},[147,653,312],{"class":157},[147,655,656,658,660,662,664,666,668,670,672,674,676,678],{"class":149,"line":344},[147,657,195],{"class":179},[147,659,198],{"class":157},[147,661,201],{"class":179},[147,663,198],{"class":157},[147,665,206],{"class":179},[147,667,165],{"class":157},[147,669,330],{"class":179},[147,671,214],{"class":157},[147,673,217],{"class":179},[147,675,183],{"class":157},[147,677,222],{"class":153},[147,679,341],{"class":157},[147,681,682,684,686,688,690,692,694,696,698,700,702,704],{"class":149,"line":373},[147,683,195],{"class":179},[147,685,198],{"class":157},[147,687,201],{"class":179},[147,689,198],{"class":157},[147,691,206],{"class":179},[147,693,165],{"class":157},[147,695,359],{"class":179},[147,697,214],{"class":157},[147,699,217],{"class":179},[147,701,183],{"class":157},[147,703,222],{"class":153},[147,705,370],{"class":157},[147,707,708,711],{"class":149,"line":382},[147,709,710],{"class":153},"  FROM",[147,712,379],{"class":161},[147,714,715,718,720,722,724,726,728,730,732,734,736,738,740,742,744,746],{"class":149,"line":428},[147,716,717],{"class":153},"        INNER JOIN",[147,719,388],{"class":157},[147,721,391],{"class":153},[147,723,394],{"class":179},[147,725,165],{"class":157},[147,727,399],{"class":179},[147,729,402],{"class":153},[147,731,405],{"class":179},[147,733,165],{"class":157},[147,735,410],{"class":179},[147,737,413],{"class":153},[147,739,394],{"class":179},[147,741,165],{"class":157},[147,743,420],{"class":179},[147,745,402],{"class":153},[147,747,425],{"class":161},[147,749,750,752,754,756,758,760,762,764,766,768],{"class":149,"line":456},[147,751,717],{"class":153},[147,753,433],{"class":157},[147,755,391],{"class":153},[147,757,438],{"class":179},[147,759,165],{"class":157},[147,761,443],{"class":179},[147,763,446],{"class":153},[147,765,405],{"class":179},[147,767,165],{"class":157},[147,769,453],{"class":179},[147,771,773,776],{"class":149,"line":772},12,[147,774,775],{"class":153},"  GROUP BY",[147,777,778],{"class":157}," root_path)\n",[147,780,782,785],{"class":149,"line":781},13,[147,783,784],{"class":153},"UPDATE",[147,786,787],{"class":157}," namespace_storage_statistics\n",[147,789,791,794,797,800,803,805,807],{"class":149,"line":790},14,[147,792,793],{"class":153},"SET",[147,795,796],{"class":157}," storage_size ",[147,798,799],{"class":153},"=",[147,801,802],{"class":179}," refresh",[147,804,165],{"class":157},[147,806,211],{"class":179},[147,808,809],{"class":157},",\n",[147,811,813,816,818,820,822,824],{"class":149,"line":812},15,[147,814,815],{"class":157},"    repository_size ",[147,817,799],{"class":153},[147,819,802],{"class":179},[147,821,165],{"class":157},[147,823,243],{"class":179},[147,825,809],{"class":157},[147,827,829,832,834,836,838,840],{"class":149,"line":828},16,[147,830,831],{"class":157},"    wiki_size ",[147,833,799],{"class":153},[147,835,802],{"class":179},[147,837,165],{"class":157},[147,839,272],{"class":179},[147,841,809],{"class":157},[147,843,845,848,850,852,854,856],{"class":149,"line":844},17,[147,846,847],{"class":157},"    lfs_objects_size ",[147,849,799],{"class":153},[147,851,802],{"class":179},[147,853,165],{"class":157},[147,855,301],{"class":179},[147,857,809],{"class":157},[147,859,861,864,866,868,870,872],{"class":149,"line":860},18,[147,862,863],{"class":157},"    build_artifacts_size ",[147,865,799],{"class":153},[147,867,802],{"class":179},[147,869,165],{"class":157},[147,871,330],{"class":179},[147,873,809],{"class":157},[147,875,877,880,882,884,886],{"class":149,"line":876},19,[147,878,879],{"class":157},"    packages_size  ",[147,881,799],{"class":153},[147,883,802],{"class":179},[147,885,165],{"class":157},[147,887,888],{"class":179},"packages_size\n",[147,890,892,894],{"class":149,"line":891},20,[147,893,376],{"class":153},[147,895,896],{"class":157}," refresh\n",[147,898,900,902,904,906,908,910,912,914,916,918,921,923,925,927,929,931],{"class":149,"line":899},21,[147,901,385],{"class":153},[147,903,388],{"class":157},[147,905,391],{"class":153},[147,907,394],{"class":179},[147,909,165],{"class":157},[147,911,168],{"class":179},[147,913,402],{"class":153},[147,915,802],{"class":179},[147,917,165],{"class":157},[147,919,920],{"class":179},"root_path",[147,922,413],{"class":153},[147,924,394],{"class":179},[147,926,165],{"class":157},[147,928,420],{"class":179},[147,930,402],{"class":153},[147,932,933],{"class":161}," 'Namespace'\n",[147,935,937,940,943,945,948,950,952,954],{"class":149,"line":936},22,[147,938,939],{"class":153},"WHERE",[147,941,942],{"class":179}," namespace_storage_statistics",[147,944,165],{"class":157},[147,946,947],{"class":179},"namespace_id",[147,949,402],{"class":153},[147,951,394],{"class":179},[147,953,165],{"class":157},[147,955,956],{"class":179},"source_id\n",[12,958,959],{},"Unlike Attempt A, a CTE will be limited to the namespace we care about instead of operating on all namespaces. The downside of it,\nis that earlier versions of MySQL do not support Common Table Expressions.",[124,961,963],{"id":962},"attempt-c-get-rid-of-the-model-and-store-the-statistics-on-redis","Attempt C: Get rid of the model and store the statistics on Redis",[12,965,966,967,972,973,978],{},"We could get rid of the model that stores the statistics in aggregated form and instead use a Redis Set.\nThis would be the ",[19,968,971],{"href":969,"rel":970},"https://handbook.gitlab.com/handbook/values/#boring-solutions",[],"boring solution"," and the fastest one\nto implement, as GitLab already includes ",[19,974,977],{"href":975,"rel":976},"https://docs.gitlab.com/development/architecture/#redis",[],"Redis"," as part of its Architecture.",[12,980,981],{},"The downside of this approach is that Redis does not provide the same persistence/consistency guarantees as PostgreSQL,\nand the namespace statistics are information we can't afford to lose in a case of a Redis failure. Also, searching for\ninformation like the largest namespaces per repository size will be easier to do in PostgreSQL than in Redis.",[124,983,985],{"id":984},"attempt-d-tag-the-root-namespace-and-its-child-namespaces","Attempt D: Tag the root namespace and its child namespaces",[12,987,988],{},"Directly relate the root namespace to its child namespaces, so\nwhenever a child namespace is created, it's also tagged with the\nroot namespace ID:",[990,991,992,1008],"table",{},[993,994,995],"thead",{},[996,997,998,1002,1005],"tr",{},[999,1000,410],"th",{"align":1001},"left",[999,1003,1004],{"align":1001},"root_id",[999,1006,1007],{"align":1001},"parent_id",[1009,1010,1011,1021,1030],"tbody",{},[996,1012,1013,1016,1018],{},[1014,1015,180],"td",{"align":1001},[1014,1017,180],{"align":1001},[1014,1019,1020],{"align":1001},"NULL",[996,1022,1023,1026,1028],{},[1014,1024,1025],{"align":1001},"2",[1014,1027,180],{"align":1001},[1014,1029,180],{"align":1001},[996,1031,1032,1035,1037],{},[1014,1033,1034],{"align":1001},"3",[1014,1036,180],{"align":1001},[1014,1038,1025],{"align":1001},[12,1040,1041],{},"To aggregate the statistics inside a namespace we'd execute something like:",[138,1043,1045],{"className":140,"code":1044,"language":142,"meta":143,"style":143},"SELECT COUNT(...)\nFROM projects\nWHERE namespace_id IN (\n  SELECT id\n  FROM namespaces\n  WHERE root_id = X\n)\n",[52,1046,1047,1057,1064,1076,1083,1090,1103],{"__ignoreMap":143},[147,1048,1049,1051,1054],{"class":149,"line":150},[147,1050,154],{"class":153},[147,1052,1053],{"class":179}," COUNT",[147,1055,1056],{"class":157},"(...)\n",[147,1058,1059,1061],{"class":149,"line":192},[147,1060,376],{"class":153},[147,1062,1063],{"class":157}," projects\n",[147,1065,1066,1068,1071,1074],{"class":149,"line":228},[147,1067,939],{"class":153},[147,1069,1070],{"class":157}," namespace_id ",[147,1072,1073],{"class":153},"IN",[147,1075,522],{"class":157},[147,1077,1078,1080],{"class":149,"line":257},[147,1079,527],{"class":153},[147,1081,1082],{"class":157}," id\n",[147,1084,1085,1087],{"class":149,"line":286},[147,1086,710],{"class":153},[147,1088,1089],{"class":157}," namespaces\n",[147,1091,1092,1095,1098,1100],{"class":149,"line":315},[147,1093,1094],{"class":153},"  WHERE",[147,1096,1097],{"class":157}," root_id ",[147,1099,799],{"class":153},[147,1101,1102],{"class":157}," X\n",[147,1104,1105],{"class":149,"line":344},[147,1106,1107],{"class":157},")\n",[12,1109,1110],{},"Even though this approach would make aggregating much easier, it has some major downsides:",[83,1112,1113,1126],{},[34,1114,1115,1116,1120,1121,165],{},"We'd have to migrate ",[1117,1118,1119],"strong",{},"all namespaces"," by adding and filling a new column. Because of the size of the table, dealing with the time/cost will not be great. The ",[19,1122,1125],{"href":1123,"rel":1124},"https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/29772#note_182201607",[],"background migration will take approximately 153 hours",[34,1127,1128],{},"The background migration has to be shipped one release before we want to start using the new data, delaying the functionality by another milestone.",[124,1130,1132],{"id":1131},"attempt-e-update-the-namespace-storage-statistics-asynchronously","Attempt E: Update the namespace storage statistics asynchronously",[12,1134,1135],{},"For this approach we continue using the incremental statistics updates we already have,\nbut we refresh them through Sidekiq jobs and in different SQL transactions:",[31,1137,1138,1150,1171,1194,1208],{},[34,1139,1140,1141,1144,1145,1147,1148,165],{},"Create a second table (",[52,1142,1143],{},"namespace_aggregation_schedules",") with two columns ",[52,1146,410],{}," and ",[52,1149,947],{},[34,1151,1152,1153,1155],{},"Whenever the statistics of a project changes, insert a row into ",[52,1154,1143],{},[83,1156,1157,1160],{},[34,1158,1159],{},"We don't insert a new row if there's already one related to the root namespace.",[34,1161,1162,1163,1170],{},"Keeping in mind the length of the transaction that involves ",[19,1164,1166,1167],{"href":108,"rel":1165},[],"updating ",[52,1168,1169],{},"project_statistics",", the insertion should be done in a different transaction and through a Sidekiq Job.",[34,1172,1173,1174],{},"After inserting the row, we schedule another worker to be executed async at two different moments:\n",[83,1175,1176,1183,1189],{},[34,1177,1178,1179,1182],{},"One enqueued for immediate execution and another one scheduled in ",[52,1180,1181],{},"1.5h"," hours.",[34,1184,1185,1186,1188],{},"We only schedule the jobs if we can obtain a ",[52,1187,1181],{}," lease on Redis on a key based on the root namespace ID.",[34,1190,1191,1192,165],{},"If we can't obtain the lease it indicates there's another aggregation already in progress or scheduled in no more than ",[52,1193,1181],{},[34,1195,1196,1197],{},"This worker will:\n",[83,1198,1199,1202],{},[34,1200,1201],{},"Update the root namespace storage statistics by querying all the namespaces through a service.",[34,1203,1204,1205,1207],{},"Delete the related ",[52,1206,1143],{}," after the update.",[34,1209,1210,1211,1213,1214],{},"Another Sidekiq job is also included to traverse any remaining rows on the ",[52,1212,1143],{}," table and schedule jobs for every pending row.\n",[83,1215,1216],{},[34,1217,1218],{},"This job is scheduled with cron to run every night (UTC).",[12,1220,1221],{},"This implementation has the following benefits:",[83,1223,1224,1229,1232,1235],{},[34,1225,1226,1227,165],{},"All the updates are done async, so we're not increasing the length of the transactions for ",[52,1228,1169],{},[34,1230,1231],{},"We're doing the update in a single SQL query.",[34,1233,1234],{},"It is compatible with PostgreSQL and MySQL.",[34,1236,1237],{},"No background migration is required.",[12,1239,1240],{},"The downsides of this approaches are:",[83,1242,1243,1255,1258],{},[34,1244,1245,1246,1249,1250,165],{},"Namespaces' statistics are updated up to ",[52,1247,1248],{},"1.5"," hours after the change is done, which means there's a brief window in time where the statistics are inaccurate. This is not a major problem because we're not currently ",[19,1251,1254],{"href":1252,"rel":1253},"https://gitlab.com/gitlab-org/gitlab-ce/issues/30421",[],"enforcing storage limits",[34,1256,1257],{},"From the implementation perspective, this approach is more complex than the migration approach (Attempt D).",[34,1259,1260,1262],{},[52,1261,1143],{}," table will see a high rate of inserts and deletes, which may require that we tune auto vacuuming for this table.",[12,1264,1265,1266,1270],{},"We went with ",[1267,1268,1269],"em",{},"Attempt E"," because updating the storage statistics asynchronously was the less problematic and\nperformant approach of aggregating the root namespaces.",[26,1272,1274],{"id":1273},"enabling-the-feature-on-gitlabcom","Enabling the feature on GitLab.com",[12,1276,1277,1278,1283],{},"Given this is a performance improvement, we have to be very careful introducing this change to GitLab.com: Which is why\nwe decided to release it under ",[19,1279,1282],{"href":1280,"rel":1281},"https://docs.gitlab.com/development/feature_flags/",[],"feature flag"," and roll it out gradually by:",[31,1285,1286,1289,1296],{},[34,1287,1288],{},"Enable it on our staging environment and measure the performance.",[34,1290,1291,1292,1295],{},"Enable it on GitLab.com on different periods for the ",[52,1293,1294],{},"gitlab-org"," group and measure the performance.",[34,1297,1298],{},"Enable it globally on GitLab.com on different periods and measure the performance.",[12,1300,1301],{},"Finally if no problem arises, we can be confident this change performs properly on GitLab.com and we can\nremove the feature flag.",[26,1303,1305],{"id":1304},"measuring-the-performance","Measuring the performance",[12,1307,1308,1309,1314],{},"To assess the execution of this approach, we monitored the ",[19,1310,1313],{"href":1311,"rel":1312},"https://dashboards.gitlab.com/d/9GOIu9Siz/sidekiq-stats?orgId=1",[],"Sidekiq dashboards"," on Kibana to ensure jobs were being executed flawlessly and without using too much memory or CPU. Particularly, we observed the \"Sidekiq queue size,\" \"Rate of running jobs,\" and \"Running jobs\" dashboards.",[124,1316,1318],{"id":1317},"on-staging","On staging",[12,1320,1321],{},"The feature was enabled globally on staging and the execution of the jobs was satisfactory. But there was barely any traffic to measure the impact of our changes:",[12,1323,1324],{},[1325,1326],"img",{"alt":1327,"src":1328},"Graph showing the queue size of the ScheduleAggregationWorker on staging","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398755/blog/Content%20Images/namespace_statistics/staging-1.png",[124,1330,1332],{"id":1331},"enabling-root-namespaces-on-gitlabcom","Enabling root namespaces on GitLab.com",[12,1334,1335,1336,1338],{},"Our results were different on GitLab.com. We first enabled it for the ",[52,1337,1294],{}," group and we quickly started to observe more traffic:",[12,1340,1341],{},[1325,1342],{"alt":1343,"src":1344},"Graph showing the queue size of the ScheduleAggregationWorker on GitLab.com","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398751/blog/Content%20Images/namespace_statistics/production-1.png",[12,1346,1347],{},[1325,1348],{"alt":1349,"src":1350},"Graph showing the running jobs of the ScheduleAggregationWorker on GitLab.com","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398751/blog/Content%20Images/namespace_statistics/production-2.png",[12,1352,1353],{},"Once we enabled the feature flag globally, the rate of running jobs increased considerably:",[12,1355,1356],{},[1325,1357],{"alt":1358,"src":1359},"Graph showing the rate running jobs of the ScheduleAggregationWorker on GitLab.com","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398751/blog/Content%20Images/namespace_statistics/production-3.png",[12,1361,1362],{},[1325,1363],{"alt":1364,"src":1365},"Graph showing the rate running jobs of the RootStatisticsWorker on GitLab.com","https://res.cloudinary.com/about-gitlab-com/image/upload/v1782398754/blog/Content%20Images/namespace_statistics/production-4.png",[26,1367,1369],{"id":1368},"root-namespaces-on-gitlabcom-today","Root namespaces on GitLab.com today",[12,1371,1372,1373,1376],{},"We currently have nearly ",[52,1374,1375],{},"400 000"," statistics stored for root namespaces on GitLab.com, which are updated at a high pace.\nBeing able to efficiently fetch those statistics allows one to easily track the top biggest repositories and/or namespaces on an instance\nand to start paving the way to enforce storage limits for groups on GitLab.com.",[12,1378,1379],{},"Learn more about this use case by reading:",[83,1381,1382,1389,1396],{},[34,1383,1384],{},[19,1385,1388],{"href":1386,"rel":1387},"https://gitlab.com/gitlab-org/gitlab-ce/issues/62214",[],"The original issue",[34,1390,1391],{},[19,1392,1395],{"href":1393,"rel":1394},"https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/28996",[],"Merge Request with the implementation",[34,1397,1398],{},[19,1399,1402],{"href":1400,"rel":1401},"https://gitlab.com/gitlab-org/gitlab-ce/issues/64092",[],"Details of the performance measured against staging and production (GitLab.com)",[12,1404,1405,1406,1411,1412,165],{},"Cover photo by ",[19,1407,1410],{"href":1408,"rel":1409},"https://unsplash.com/@bill_oxford?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText",[],"Bill Oxford"," on ",[19,1413,1416],{"href":1414,"rel":1415},"https://unsplash.com/search/photos/engineering?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText",[],"Unsplash",[1418,1419,1420],"style",{},"html pre.shiki code .sD7c4, html code.shiki .sD7c4{--shiki-default:#D73A49}html pre.shiki code .sgsFI, html code.shiki .sgsFI{--shiki-default:#24292E}html pre.shiki code .sYBdl, html code.shiki .sYBdl{--shiki-default:#032F62}html pre.shiki code .sYu0t, html code.shiki .sYu0t{--shiki-default:#005CC5}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":143,"searchDepth":192,"depth":192,"links":1422},[1423,1424,1431,1432,1436],{"id":28,"depth":192,"text":29},{"id":121,"depth":192,"text":122,"children":1425},[1426,1427,1428,1429,1430],{"id":126,"depth":228,"text":127},{"id":495,"depth":228,"text":496},{"id":962,"depth":228,"text":963},{"id":984,"depth":228,"text":985},{"id":1131,"depth":228,"text":1132},{"id":1273,"depth":192,"text":1274},{"id":1304,"depth":192,"text":1305,"children":1433},[1434,1435],{"id":1317,"depth":228,"text":1318},{"id":1331,"depth":228,"text":1332},{"id":1368,"depth":192,"text":1369},"engineering","2019-10-14","Explore all the different engineering approaches to store and update the namespace statistics in a performant manner.","md",null,false,"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749672677/Blog/Hero%20Images/metalgears_databasecasestudy.jpg",{},true,"/en-us/blog/database-case-study-store-and-update-namespace-statistics",{"title":5,"description":1439,"ogTitle":5,"ogDescription":1439,"noIndex":1442,"ogImage":1443,"ogUrl":1448,"ogSiteName":1449,"ogType":1450,"canonicalUrls":1448},"https://about.gitlab.com/blog/database-case-study-store-and-update-namespace-statistics","https://about.gitlab.com","article","database-case-study-store-and-update-namespace-statistics","en-us/blog/database-case-study-store-and-update-namespace-statistics",[1454],"inside GitLab","BlogPost","00792uSzny53fal1cv08B8uvynyzHUZewV0N59OlFG4",{"logo":1458,"freeTrial":1463,"sales":1468,"login":1473,"items":1478,"search":1814,"minimal":1846,"duo":1865,"switchNav":1874,"pricingDeployment":1885},{"config":1459},{"href":1460,"dataGaName":1461,"dataGaLocation":1462},"/","gitlab logo","header",{"text":1464,"config":1465},"Get free trial",{"href":1466,"dataGaName":1467,"dataGaLocation":1462},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com&glm_content=default-saas-trial/","free trial",{"text":1469,"config":1470},"Request a demo",{"href":1471,"dataGaName":1472,"dataGaLocation":1462},"/request-a-demo/","sales",{"text":1474,"config":1475},"Sign in",{"href":1476,"dataGaName":1477,"dataGaLocation":1462},"https://gitlab.com/users/sign_in/","sign in",[1479,1565,1653,1658,1738,1792],{"text":1480,"left":1445,"config":1481,"menu":1483},"Platform",{"dataNavLevelOne":1482},"platform",{"type":1484,"link":1485,"columns":1489,"feature":1554},"lists",{"text":1486,"config":1487},"Explore the Platform",{"href":1488,"dataGaName":1482,"dataGaLocation":1462},"/platform/",[1490,1513,1536],{"title":1491,"items":1492},"DevOps",[1493,1498,1503,1508],{"text":1494,"config":1495},"CI/CD",{"href":1496,"dataGaLocation":1462,"dataGaName":1497},"/solutions/continuous-integration/","ci/cd",{"text":1499,"config":1500},"Source Code Management",{"href":1501,"dataGaLocation":1462,"dataGaName":1502},"/solutions/source-code-management/","source code management",{"text":1504,"config":1505},"Agile Delivery",{"href":1506,"dataGaLocation":1462,"dataGaName":1507},"/solutions/agile-delivery/","agile delivery",{"text":1509,"config":1510},"Artifact Management",{"href":1511,"dataGaLocation":1462,"dataGaName":1512},"/artifact-central/","artifact management",{"title":1514,"items":1515},"Security & Governance",[1516,1521,1526,1531],{"text":1517,"config":1518},"Application Security Testing",{"href":1519,"dataGaLocation":1462,"dataGaName":1520},"/solutions/application-security-testing/","application security testing",{"text":1522,"config":1523},"Governance & Compliance",{"href":1524,"dataGaLocation":1462,"dataGaName":1525},"/solutions/software-compliance/","governance and compliance",{"text":1527,"config":1528},"Secrets Management",{"href":1529,"dataGaLocation":1462,"dataGaName":1530},"/gitlab-secrets-manager/","secrets management",{"text":1532,"config":1533},"Supply Chain Security",{"href":1534,"dataGaLocation":1462,"dataGaName":1535},"/solutions/supply-chain/","supply chain security",{"title":1537,"items":1538},"Agentic AI & Context",[1539,1544,1549],{"text":1540,"config":1541},"Duo Agent Platform",{"href":1542,"dataGaLocation":1462,"dataGaName":1543},"/gitlab-duo-agent-platform/","duo agent platform",{"text":1545,"config":1546},"Orbit Context Graph",{"href":1547,"dataGaLocation":1462,"dataGaName":1548},"/gitlab-orbit/","orbit",{"text":1550,"config":1551},"Visibility & Measurement",{"href":1552,"dataGaLocation":1462,"dataGaName":1553},"/solutions/visibility-measurement/","visibility and measurement",{"config":1555,"title":1558,"text":1559,"link":1560},{"background":1556,"textColor":1557},"url('https://res.cloudinary.com/about-gitlab-com/image/upload/v1790185102/o7dn32anqcb6z8dgd3as.jpg')","#000","GitLab Orbit is generally available","Higher agent accuracy, lower token cost",{"text":1561,"config":1562},"Read the announcement",{"href":1563,"dataGaName":1564,"dataGaLocation":1462},"/blog/gitlab-orbit-ga/","orbit ga announcement",{"text":1566,"left":1445,"config":1567,"menu":1569},"Solutions",{"dataNavLevelOne":1568},"solutions",{"type":1484,"link":1570,"columns":1574,"feature":1644},{"text":1571,"config":1572},"View all Solutions",{"href":1573,"dataGaName":1568,"dataGaLocation":1462},"/solutions/",[1575,1593,1611],{"title":1576,"items":1577},"Outcomes",[1578,1583,1588],{"text":1579,"config":1580},"DevOps Modernization",{"href":1581,"dataGaLocation":1462,"dataGaName":1582},"/assessments/devops-modernization-assessment/","devops modernization",{"text":1584,"config":1585},"Security Modernization",{"href":1586,"dataGaLocation":1462,"dataGaName":1587},"/assessments/security-modernization-assessment/","security modernization",{"text":1589,"config":1590},"AI Modernization",{"href":1591,"dataGaLocation":1462,"dataGaName":1592},"/assessments/ai-modernization-assessment/","ai modernization",{"title":1594,"items":1595},"By size",[1596,1601,1606],{"text":1597,"config":1598},"Enterprise",{"href":1599,"dataGaLocation":1462,"dataGaName":1600},"/enterprise/","enterprise",{"text":1602,"config":1603},"Small Business",{"href":1604,"dataGaLocation":1462,"dataGaName":1605},"/small-business/","small business",{"text":1607,"config":1608},"Startups",{"href":1609,"dataGaLocation":1462,"dataGaName":1610},"/solutions/startups/","startups",{"title":1612,"items":1613},"Industries",[1614,1619,1624,1629,1634,1639],{"text":1615,"config":1616},"Financial Services",{"href":1617,"dataGaLocation":1462,"dataGaName":1618},"/solutions/finance/","financial services",{"text":1620,"config":1621},"Public Sector",{"href":1622,"dataGaLocation":1462,"dataGaName":1623},"/solutions/public-sector/","public sector",{"text":1625,"config":1626},"Telecommunications",{"href":1627,"dataGaLocation":1462,"dataGaName":1628},"/solutions/telecommunications/","telecommunications",{"text":1630,"config":1631},"Automotive",{"href":1632,"dataGaLocation":1462,"dataGaName":1633},"/solutions/automotive/","automotive",{"text":1635,"config":1636},"Education",{"href":1637,"dataGaLocation":1462,"dataGaName":1638},"/solutions/education/","education",{"text":1640,"config":1641},"Aerospace",{"href":1642,"dataGaLocation":1462,"dataGaName":1643},"/solutions/aerospace/","aerospace",{"config":1645,"title":1646,"text":1647,"link":1648},{"background":1556,"textColor":1557},"GitLab Security Standard","Learn how to harden your software factory and let AI agents earn autonomy, without trading away security.",{"text":1649,"config":1650},"Explore the standard",{"href":1651,"dataGaName":1652,"dataGaLocation":1462},"/gitlab-security-standard/","gitlab security standard",{"text":1654,"config":1655},"Pricing",{"href":1656,"dataGaName":1657,"dataGaLocation":1462,"dataNavLevelOne":1657},"/pricing/","pricing",{"text":1659,"config":1660,"menu":1662},"Resources",{"dataNavLevelOne":1661},"resources",{"type":1484,"link":1663,"columns":1667,"feature":1729},{"text":1664,"config":1665},"View all resources",{"href":1666,"dataGaName":1661,"dataGaLocation":1462},"/resources/",[1668,1701],{"title":1669,"items":1670},"Discover",[1671,1676,1681,1686,1691,1696],{"text":1672,"config":1673},"Docs",{"href":1674,"dataGaName":1675,"dataGaLocation":1462},"https://docs.gitlab.com/","docs",{"text":1677,"config":1678},"University",{"href":1679,"dataGaName":1680,"dataGaLocation":1462},"https://university.gitlab.com/","university",{"text":1682,"config":1683},"Demo Series",{"href":1684,"dataGaName":1685,"dataGaLocation":1462},"/gitlab-technical-demo-series/","demo series",{"text":1687,"config":1688},"Demo Hub",{"href":1689,"dataGaName":1690,"dataGaLocation":1462},"/demo-hub/","demo hub",{"text":1692,"config":1693},"Services",{"href":1694,"dataGaName":1695,"dataGaLocation":1462},"/services/","services",{"text":1697,"config":1698},"Well Architected",{"href":1699,"dataGaName":1700,"dataGaLocation":1462},"/resources/well-architected/","well architected",{"title":1702,"items":1703},"Connect",[1704,1709,1714,1719,1724],{"text":1705,"config":1706},"Blog",{"href":1707,"dataGaName":1708,"dataGaLocation":1462},"/blog/","blog",{"text":1710,"config":1711},"Community",{"href":1712,"dataGaName":1713,"dataGaLocation":1462},"/community/","community",{"text":1715,"config":1716},"Customers",{"href":1717,"dataGaName":1718,"dataGaLocation":1462},"/customers/","customers",{"text":1720,"config":1721},"Partners",{"href":1722,"dataGaName":1723,"dataGaLocation":1462},"/partners/","partners",{"text":1725,"config":1726},"Events",{"href":1727,"dataGaName":1728,"dataGaLocation":1462},"/events/","events",{"config":1730,"title":1731,"text":1732,"link":1733},{"background":1556,"textColor":1557},"What’s new in GitLab","Stay updated with our latest features and improvements.",{"text":1734,"config":1735},"Read the latest",{"href":1736,"dataGaName":1737,"dataGaLocation":1462},"/whats-new/","whats new",{"text":1739,"config":1740,"menu":1742},"Company",{"dataNavLevelOne":1741},"company",{"type":1484,"columns":1743},[1744],{"items":1745},[1746,1751,1757,1762,1767,1772,1777,1782,1787],{"text":1747,"config":1748},"About",{"href":1749,"dataGaName":1750,"dataGaLocation":1462},"/company/","about",{"text":1752,"config":1753,"footerGa":1756},"Jobs",{"href":1754,"dataGaName":1755,"dataGaLocation":1462},"/jobs/","jobs",{"dataGaName":1755},{"text":1758,"config":1759},"Press",{"href":1760,"dataGaName":1761,"dataGaLocation":1462},"/press/","press",{"text":1763,"config":1764},"Handbook",{"href":1765,"dataGaName":1766,"dataGaLocation":1462},"https://handbook.gitlab.com/","handbook",{"text":1768,"config":1769},"Leadership",{"href":1770,"dataGaName":1771,"dataGaLocation":1462},"/company/team/e-group/","leadership",{"text":1773,"config":1774},"Investor relations",{"href":1775,"dataGaName":1776,"dataGaLocation":1462},"https://ir.gitlab.com/overview/default.aspx","investor relations",{"text":1778,"config":1779},"Trust Center",{"href":1780,"dataGaName":1781,"dataGaLocation":1462},"/security/","trust center",{"text":1783,"config":1784},"AI Transparency Center",{"href":1785,"dataGaName":1786,"dataGaLocation":1462},"/ai-transparency-center/","ai transparency center",{"text":1788,"config":1789},"Newsletter",{"href":1790,"dataGaName":1791,"dataGaLocation":1462},"/company/contact/#contact-forms","newsletter",{"text":1793,"config":1794,"menu":1795},"Contact us",{"dataNavLevelOne":1741},{"type":1484,"columns":1796},[1797],{"items":1798},[1799,1804,1809],{"text":1800,"config":1801},"Talk to sales",{"href":1802,"dataGaName":1803,"dataGaLocation":1462},"/sales/","talk to sales",{"text":1805,"config":1806},"Support portal",{"href":1807,"dataGaName":1808,"dataGaLocation":1462},"https://support.gitlab.com/hc/en-us","support portal",{"text":1810,"config":1811},"Customer portal",{"href":1812,"dataGaName":1813,"dataGaLocation":1462},"https://customers.gitlab.com/customers/sign_in/","customer portal",{"close":1815,"login":1816,"suggestions":1823},"Close",{"text":1817,"link":1818},"To search repositories and projects, login to",{"text":1819,"config":1820},"gitlab.com",{"href":1476,"dataGaName":1821,"dataGaLocation":1822},"search login","search",{"text":1824,"default":1825},"Suggestions",[1826,1829,1832,1834,1838,1842],{"text":1827,"config":1828},"GitLab Duo Agent Platform",{"href":1542,"dataGaName":1827,"dataGaLocation":1822},{"text":1830,"config":1831},"Code Suggestions (AI)",{"href":1542,"dataGaName":1830,"dataGaLocation":1822},{"text":1494,"config":1833},{"href":1496,"dataGaName":1494,"dataGaLocation":1822},{"text":1835,"config":1836},"GitLab on AWS",{"href":1837,"dataGaName":1835,"dataGaLocation":1822},"/partners/technology-partners/aws/",{"text":1839,"config":1840},"GitLab on Google Cloud",{"href":1841,"dataGaName":1839,"dataGaLocation":1822},"/partners/technology-partners/google-cloud-platform/",{"text":1843,"config":1844},"Why GitLab?",{"href":1845,"dataGaName":1843,"dataGaLocation":1822},"/why-gitlab/",{"freeTrial":1847,"mobileIcon":1852,"desktopIcon":1857,"secondaryButton":1860},{"text":1848,"config":1849},"Start free trial",{"href":1850,"dataGaName":1467,"dataGaLocation":1851},"https://gitlab.com/-/trials/new/","nav",{"altText":1853,"config":1854},"Gitlab Icon",{"src":1855,"dataGaName":1856,"dataGaLocation":1851},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203874/jypbw1jx72aexsoohd7x.svg","gitlab icon",{"altText":1853,"config":1858},{"src":1859,"dataGaName":1856,"dataGaLocation":1851},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1758203875/gs4c8p8opsgvflgkswz9.svg",{"text":1861,"config":1862},"Get Started",{"href":1863,"dataGaName":1864,"dataGaLocation":1851},"https://gitlab.com/-/trial_registrations/new?glm_source=about.gitlab.com/get-started/","get started",{"freeTrial":1866,"mobileIcon":1870,"desktopIcon":1872},{"text":1867,"config":1868},"Learn more about GitLab Duo",{"href":1542,"dataGaName":1869,"dataGaLocation":1851},"gitlab duo",{"altText":1853,"config":1871},{"src":1855,"dataGaName":1856,"dataGaLocation":1851},{"altText":1853,"config":1873},{"src":1859,"dataGaName":1856,"dataGaLocation":1851},{"button":1875,"mobileIcon":1880,"desktopIcon":1882},{"text":1876,"config":1877},"/switch",{"href":1878,"dataGaName":1879,"dataGaLocation":1851},"#contact","switch",{"altText":1853,"config":1881},{"src":1855,"dataGaName":1856,"dataGaLocation":1851},{"altText":1853,"config":1883},{"src":1884,"dataGaName":1856,"dataGaLocation":1851},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1773335277/ohhpiuoxoldryzrnhfrh.png",{"freeTrial":1886,"mobileIcon":1891,"desktopIcon":1893},{"text":1887,"config":1888},"Back to pricing",{"href":1656,"dataGaName":1889,"dataGaLocation":1851,"icon":1890},"back to pricing","GoBack",{"altText":1853,"config":1892},{"src":1855,"dataGaName":1856,"dataGaLocation":1851},{"altText":1853,"config":1894},{"src":1859,"dataGaName":1856,"dataGaLocation":1851},{"title":1896,"button":1897,"config":1901},"GitLab Orbit is generally available. Increase agent accuracy and lower token cost",{"text":1561,"config":1898},{"href":1563,"dataGaName":1899,"dataGaLocation":1900},"orbit-ga-banner","global-banner",{"layout":1902,"disabled":1442},"release",{"data":1904},{"text":1905,"config":1906,"items":1911,"minimal":2139},"Git is a trademark of Software Freedom Conservancy and our use of 'GitLab' is under license",{"twitter":1907,"facebook":1908,"youtube":1909,"linkedin":1910},"https://twitter.com/gitlab","https://www.facebook.com/gitlab","https://www.youtube.com/channel/UCnMGQ8QHMAnVIsI3xJrihhg","https://www.linkedin.com/company/gitlab-com",[1912,1960,2019,2066,2107],{"title":1654,"links":1913,"subMenu":1929},[1914,1919,1924],{"text":1915,"config":1916},"View plans",{"href":1656,"dataGaName":1917,"dataGaLocation":1918},"view plans","footer",{"text":1920,"config":1921},"Why Premium?",{"href":1922,"dataGaName":1923,"dataGaLocation":1918},"/pricing/premium/","why premium",{"text":1925,"config":1926},"Why Ultimate?",{"href":1927,"dataGaName":1928,"dataGaLocation":1918},"/pricing/ultimate/","why ultimate",[1930],{"title":1931,"links":1932},"Contact Us",[1933,1936,1938,1940,1945,1950,1955],{"text":1934,"config":1935},"Contact sales",{"href":1802,"dataGaName":1472,"dataGaLocation":1918},{"text":1805,"config":1937},{"href":1807,"dataGaName":1808,"dataGaLocation":1918},{"text":1810,"config":1939},{"href":1812,"dataGaName":1813,"dataGaLocation":1918},{"text":1941,"config":1942},"Status",{"href":1943,"dataGaName":1944,"dataGaLocation":1918},"https://status.gitlab.com/","status",{"text":1946,"config":1947},"Terms of use",{"href":1948,"dataGaName":1949,"dataGaLocation":1918},"/terms/","terms of use",{"text":1951,"config":1952},"Privacy statement",{"href":1953,"dataGaName":1954,"dataGaLocation":1918},"/privacy/","privacy statement",{"text":1956,"config":1957},"Cookie preferences",{"dataGaName":1958,"dataGaLocation":1918,"id":1959,"isOneTrustButton":1445},"cookie preferences","ot-sdk-btn",{"title":1480,"links":1961,"subMenu":1977},[1962,1965,1967,1969,1971,1973],{"text":1963,"config":1964},"Explore the platform",{"href":1488,"dataGaName":1482,"dataGaLocation":1918},{"text":1540,"config":1966},{"href":1542,"dataGaName":1543,"dataGaLocation":1918},{"text":1494,"config":1968},{"href":1496,"dataGaName":1497,"dataGaLocation":1918},{"text":1545,"config":1970},{"href":1547,"dataGaName":1548,"dataGaLocation":1918},{"text":1527,"config":1972},{"href":1529,"dataGaName":1530,"dataGaLocation":1918},{"text":1974,"config":1975},"Why GitLab",{"href":1845,"dataGaName":1976,"dataGaLocation":1918},"why gitlab",[1978],{"title":1979,"links":1980},"Topics",[1981,1985,1990,1994,1999,2004,2009,2014],{"text":1494,"config":1982},{"href":1983,"dataGaName":1984,"dataGaLocation":1918},"/topics/ci-cd/","cicd",{"text":1986,"config":1987},"GitOps",{"href":1988,"dataGaName":1989,"dataGaLocation":1918},"/topics/gitops/","gitops",{"text":1491,"config":1991},{"href":1992,"dataGaName":1993,"dataGaLocation":1918},"/topics/devops/","devops",{"text":1995,"config":1996},"Version Control",{"href":1997,"dataGaName":1998,"dataGaLocation":1918},"/topics/version-control/","version control",{"text":2000,"config":2001},"DevSecOps",{"href":2002,"dataGaName":2003,"dataGaLocation":1918},"/topics/devsecops/","devsecops",{"text":2005,"config":2006},"Cloud Native",{"href":2007,"dataGaName":2008,"dataGaLocation":1918},"/topics/cloud-native/","cloud native",{"text":2010,"config":2011},"AI for Coding",{"href":2012,"dataGaName":2013,"dataGaLocation":1918},"/topics/devops/ai-for-coding/","ai for coding",{"text":2015,"config":2016},"Agentic AI",{"href":2017,"dataGaName":2018,"dataGaLocation":1918},"/topics/agentic-ai/","agentic ai",{"title":1566,"links":2020},[2021,2024,2027,2030,2033,2036,2038,2040,2042,2044,2046,2049,2051,2054,2058,2062],{"text":2022,"config":2023},"DevOps modernization",{"href":1581,"dataGaName":1582,"dataGaLocation":1918},{"text":2025,"config":2026},"Security modernization",{"href":1586,"dataGaName":1587,"dataGaLocation":1918},{"text":2028,"config":2029},"AI modernization",{"href":1591,"dataGaName":1592,"dataGaLocation":1918},{"text":2031,"config":2032},"Financial services",{"href":1617,"dataGaName":1618,"dataGaLocation":1918},{"text":2034,"config":2035},"Public sector",{"href":1622,"dataGaName":1623,"dataGaLocation":1918},{"text":1625,"config":2037},{"href":1627,"dataGaName":1628,"dataGaLocation":1918},{"text":1630,"config":2039},{"href":1632,"dataGaName":1633,"dataGaLocation":1918},{"text":1635,"config":2041},{"href":1637,"dataGaName":1638,"dataGaLocation":1918},{"text":1640,"config":2043},{"href":1642,"dataGaName":1643,"dataGaLocation":1918},{"text":1597,"config":2045},{"href":1599,"dataGaName":1600,"dataGaLocation":1918},{"text":2047,"config":2048},"Small business",{"href":1604,"dataGaName":1605,"dataGaLocation":1918},{"text":1607,"config":2050},{"href":1609,"dataGaName":1610,"dataGaLocation":1918},{"text":1986,"config":2052},{"href":2053,"dataGaName":1989,"dataGaLocation":1918},"/solutions/gitops/",{"text":2055,"config":2056},"Software composition analysis",{"href":1534,"dataGaName":2057,"dataGaLocation":1918},"software composition analysis",{"text":2059,"config":2060},"Value stream management",{"href":1552,"dataGaName":2061,"dataGaLocation":1918},"value stream management",{"text":2063,"config":2064},"All solutions",{"href":1573,"dataGaName":2065,"dataGaLocation":1918},"all solutions",{"title":1659,"links":2067},[2068,2073,2078,2080,2082,2084,2086,2088,2090,2092,2094,2096,2098,2100,2103],{"text":2069,"config":2070},"Install",{"href":2071,"dataGaName":2072,"dataGaLocation":1918},"/install/","install",{"text":2074,"config":2075},"Quick start guides",{"href":2076,"dataGaName":2077,"dataGaLocation":1918},"/get-started/","quick setup checklists",{"text":1672,"config":2079},{"href":1674,"dataGaName":1675,"dataGaLocation":1918},{"text":1677,"config":2081},{"href":1679,"dataGaName":1680,"dataGaLocation":1918},{"text":1682,"config":2083},{"href":1684,"dataGaName":1685,"dataGaLocation":1918},{"text":1687,"config":2085},{"href":1689,"dataGaName":1690,"dataGaLocation":1918},{"text":1692,"config":2087},{"href":1694,"dataGaName":1695,"dataGaLocation":1918},{"text":1705,"config":2089},{"href":1707,"dataGaName":1708,"dataGaLocation":1918},{"text":1710,"config":2091},{"href":1712,"dataGaName":1713,"dataGaLocation":1918},{"text":1715,"config":2093},{"href":1717,"dataGaName":1718,"dataGaLocation":1918},{"text":1720,"config":2095},{"href":1722,"dataGaName":1723,"dataGaLocation":1918},{"text":1725,"config":2097},{"href":1727,"dataGaName":1728,"dataGaLocation":1918},{"text":1788,"config":2099},{"href":1790,"dataGaName":1791,"dataGaLocation":1918},{"text":2101,"config":2102},"What's new",{"href":1736,"dataGaName":1737,"dataGaLocation":1918},{"text":2104,"config":2105},"All resources",{"href":1666,"dataGaName":2106,"dataGaLocation":1918},"all resources",{"title":1739,"links":2108},[2109,2111,2113,2115,2117,2119,2121,2123,2125,2129,2134],{"text":1747,"config":2110},{"href":1749,"dataGaName":1741,"dataGaLocation":1918},{"text":1752,"config":2112},{"href":1754,"dataGaName":1755,"dataGaLocation":1918},{"text":1758,"config":2114},{"href":1760,"dataGaName":1761,"dataGaLocation":1918},{"text":1763,"config":2116},{"href":1765,"dataGaName":1766,"dataGaLocation":1918},{"text":1768,"config":2118},{"href":1770,"dataGaName":1771,"dataGaLocation":1918},{"text":1773,"config":2120},{"href":1775,"dataGaName":1776,"dataGaLocation":1918},{"text":1778,"config":2122},{"href":1780,"dataGaName":1781,"dataGaLocation":1918},{"text":1783,"config":2124},{"href":1785,"dataGaName":1786,"dataGaLocation":1918},{"text":2126,"config":2127},"Sustainability",{"href":2128,"dataGaName":2126,"dataGaLocation":1918},"/sustainability/",{"text":2130,"config":2131},"Diversity, inclusion and belonging (DIB)",{"href":2132,"dataGaName":2133,"dataGaLocation":1918},"/diversity-inclusion-belonging/","Diversity, inclusion and belonging",{"text":2135,"config":2136},"Modern Slavery Transparency Statement",{"href":2137,"dataGaName":2138,"dataGaLocation":1918},"https://handbook.gitlab.com/handbook/legal/modern-slavery-act-transparency-statement/","modern slavery transparency statement",{"items":2140},[2141,2144,2147],{"text":2142,"config":2143},"Terms",{"href":1948,"dataGaName":1949,"dataGaLocation":1918},{"text":2145,"config":2146},"Cookies",{"dataGaName":1958,"dataGaLocation":1918,"id":1959,"isOneTrustButton":1445},{"text":2148,"config":2149},"Privacy",{"href":1953,"dataGaName":1954,"dataGaLocation":1918},[2151],{"id":2152,"title":7,"body":1441,"config":2153,"content":2155,"description":1441,"extension":2159,"meta":2160,"navigation":1445,"path":2161,"seo":2162,"stem":2163,"__hash__":2164},"blogAuthors/en-us/blog/authors/mayra-cabrera.yml",{"template":2154},"BlogAuthor",{"name":7,"config":2156},{"headshot":2157,"ctfId":2158},"https://res.cloudinary.com/about-gitlab-com/image/upload/v1749663224/Blog/Author%20Headshots/mayra-cabrera-headshot.jpg","mayracabrera","yml",{},"/en-us/blog/authors/mayra-cabrera",{},"en-us/blog/authors/mayra-cabrera","GCqp-lemVuilgAOb64pels-pdypKfj3yN8pWtqP96o8",[2166,2174,2182],{"title":2167,"description":2168,"heroImage":2169,"category":1437,"date":2170,"authors":2171,"slug":2173,"externalUrl":1441},"Two front doors: Module-level access in a Django GRC app","A technical deep-dive on restructuring a Django internal tool to support two distinct GitLab teams: Security Compliance and Internal Audit.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1750097663/Blog/Hero%20Images/Blog/Hero%20Images/Workflow%201800x945_2gQoQIbY9NvjLFpXtsxtXy_1750097663612.png","2026-10-05",[2172],"Donovan Felton","module-level-access-in-a-django-grc-app",{"title":2175,"description":2176,"heroImage":2177,"category":1437,"date":2178,"authors":2179,"slug":2181,"externalUrl":1441},"How GitLab reduced code-per-agentic-flow ratio by 45%","Learn how Flow Registry, a component-based framework that compiles YAML configurations into fully functional LangGraph flows, helped improve scalability and more.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1774465167/n5hlvrsrheadeccyr1oz.png","2026-09-22",[2180],"Mikolaj Wawrzyniak","how-gitlab-reduced-code-per-agentic-flow-ratio",{"title":2183,"description":2184,"heroImage":2185,"category":1437,"date":2186,"authors":2187,"slug":2189,"externalUrl":1441},"Co-Create: Building GitLab with our users","How GitLab users collaborated with us to build practical product improvements in the first half of 2026.","https://res.cloudinary.com/about-gitlab-com/image/upload/v1750099203/Blog/Hero%20Images/Blog/Hero%20Images/blog-image-template-1800x945%20%2820%29_2bJGC5ZP3WheoqzlLT05C5_1750099203484.png","2026-09-10",[2188],"Isa Huerga","co-create-h1-2026",{"header":2191,"text":2192,"button":2196,"disclaimer":2199},"Start your free\n\n30-day GitLab trial\n",[2193,2194,2195],"GitLab Duo Agent Platform access","Try our most advanced features","Automate complex tasks with AI",{"text":1464,"config":2197},{"href":2198,"dataGaName":1467,"dataGaLocation":1708},"https://gitlab.com/-/trials/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/blog/","No credit card required.",{"header":2201,"blurb":2202,"button":2203,"secondaryButton":2208},"Start building faster today","See what your team can do with the intelligent orchestration platform for DevSecOps.\n",{"text":2204,"config":2205},"Get your free trial",{"href":2206,"dataGaName":1467,"dataGaLocation":2207},"https://gitlab.com/-/trial_registrations/new?glm_content=default-saas-trial&glm_source=about.gitlab.com/","feature",{"text":1934,"config":2209},{"href":1802,"dataGaName":1472,"dataGaLocation":2207},1794911775049]