-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: 7.0.0, 8.0.0, 8.2.0, 9.0.0-rc0, 8.3.0
-
Component/s: Catalog, Performance
-
None
-
Catalog and Routing
-
2
-
馃煢 Shard Catalog
-
None
-
None
-
None
-
None
-
None
-
None
The list of views of each DB is backed by the ViewsForDatabase data structure, which does not have copy-on-write semantics.
When creating or dropping a view, this data structure is copied is several places, so performance degrades with the number of views:
- Creating/dropping a view has O(N) complexity where N=number of existing views.
- Creating/dropping N views has O(N^2) complexity
聽
This could be solved by implementing copy-on-write semantics or some similar kind of incremental update strategy for ViewsForDtabase.
聽
Practical impact
In practice performance degrades noticeably when a DB has 1000s of views or viewful timeseries collections.
With N=15000 views, on a 3 node RS, optimized build, m7g.2xlarge VM w/ gp3 storage):
- Creating 2000 views --> 35 seconds (18ms per view)
- Drop 2000 views --> 75 seconds (38ms per view)
聽
Frame graphs for create view
In those flame graphs most of the time spent in the commit of the WUOW (e.g. CollectionCatalog::write) and CollectionCatalog::createView copying and destroying the ViewsForDatabase data structure.
聽
Replica set primary:

聽
Replica set secondary:

聽
Frame graphs for drop view
聽Those frame graphs show the known performance issue in SERVER-78615聽aside from the same performance impact of copying/destroying聽ViewsForDatabase:
聽
Replica set primary:

聽
Replica set secondary:

聽
聽
- is related to
-
SERVER-78615 Poor view drop performance leads to replication lag
-
- Backlog
-
- related to
-
SERVER-77572 Create workload to test create and drop of many views
-
- Backlog
-
-
SERVER-46874 Create view becomes very slow when system has many (10000+) views
-
- Closed
-