Skip to content

Commit 4f7b2b5

Browse files
authored
Merge pull request #9985 from dahfjkg/dat/association-storage-migration-performance
Add association storage migration performance measurements
2 parents 1b92dd8 + 1afed65 commit 4f7b2b5

File tree

7 files changed

+76
-2
lines changed

7 files changed

+76
-2
lines changed

content/en/docs/refguide/modeling/domain-model/associations/association-storage.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Association storage options give you more control over how associations are impl
1111

1212
## Association Tables vs. Direct Associations
1313

14-
You can choose whether to implement some associations as direct associations as opposed to using association tables. This means that the ID of the **Child** object is stored as a foreign key column of the **Parent** object (for example the "many" side of the association) in the underlying database table. This removes the need for an association table.
14+
You can choose whether to implement some associations as direct associations as opposed to using association tables. This means that the ID of the **Child** object is stored as a foreign key column of the **Parent** object (for example the "many" side of the association) in the underlying database table. This removes the need for an association table. In most cases, this is the recommended option.
1515

1616
Association tables have the advantage that you don't have to worry about the [multiplicity](/refguide/association-properties/#multiplicity) or [navigability](/refguide/association-properties/#navigability) of the associations. You can change things as your domain model evolves.
1717

@@ -58,6 +58,6 @@ For more information, see the [Association Storage](/refguide/association-proper
5858
Before deciding to switch from an association table to a direct association, bear the following in mind:
5959

6060
* Do not use direct associations in modules which are designed to be imported into apps (for example, Marketplace modules) as this could cause unexpected migrations in an app the module is being imported into.
61-
* Associations have to be rewritten to the database so migration can take a long time, especially where you have a large amount of data already stored in your database
61+
* Associations have to be rewritten to the database so migration can take a long time, especially where you have a large amount of data already stored in your database — Mendix has done some testing around this and you can find the results in [Association Storage Migration Time](/refguide/association-storage-migration-time/)
6262
* Queries are not always faster, and might not be faster in your use case
6363
* If you have written any custom SQL that accesses Mendix tables directly, this might break, but existing XPaths and OQL queries will not be affected
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
---
2+
title: "Association Storage Migration Time"
3+
url: /refguide/association-storage-migration-time/
4+
weight: 15
5+
---
6+
7+
## Introduction
8+
9+
Mendix allows you to change [association storage type](/refguide/association-storage/) for many-to-one and one-to-one associations and switch between Association Tables (legacy option) or Direct Associations (recommended option). Changing the association storage type in an already deployed app leads to data synchronization which can take significant time depending on the amount of data in the database.
10+
11+
This page contains timings for an example association storage migration that can help you estimate data migration time for your app.
12+
13+
## Scenarios
14+
15+
We performed association storage type migration for associations in the domain model shown below:
16+
17+
{{< figure src="/attachments/refguide/runtime/data-storage/association-storage-migration-time/association-storage-model.png" alt="Test model for association storage migration - click to enlarge" class="no-border" >}}
18+
(*Click the image to enlarge*)
19+
20+
This domain model was used to measure migration time for the following cases:
21+
22+
- **Many-to-one association:** Each of N objects of entity `Many` is associated to one of 10 objects of entity `ToOne`
23+
- **One-to-one association:** Each of N objects of entity `One` is associated to one of N objects of entity `ToOne`
24+
- **10 many-to-one associations in one entity:** Each of N objects of entity `Multiple` has 10 associations to objects of entities `Target01` to `Target10`. This means that there are 10*N associations being migrated.
25+
26+
For every database vendor, we ran migrations for 3 different values of N. For each such configuration, we executed the migration 10 times and measured the average migration time over those 10 runs.
27+
28+
## Measurements
29+
30+
All the time measurements are in seconds (s).
31+
32+
### PostgreSQL
33+
34+
|Associations per table (N)|Many to one|One to one|Many to one, 10 associations in one entity|
35+
|-|-|-|-|
36+
|20K|0.176 s|0.194 s|1.08 s|
37+
|1M|8.3 s|9.2 s|38.1 s|
38+
|20M|199 s|222 s|850 s|
39+
40+
{{< figure src="/attachments/refguide/runtime/data-storage/association-storage-migration-time/storage-migration-postgres.png" alt="Migration time measurements for PostgreSQL - click to enlarge" class="no-border" >}}
41+
(*Click the image to enlarge*)
42+
43+
### SQL Server
44+
45+
|Associations per table (N)|Many to one|One to one|Many to one, 10 associations in one entity|
46+
|-|-|-|-|
47+
|20K|0.177 s|0.177 s|0.94 s|
48+
|1M|8.3 s|8 s|42 s|
49+
|20M|183 s|184 s|1013 s|
50+
51+
{{< figure src="/attachments/refguide/runtime/data-storage/association-storage-migration-time/storage-migration-mssql.png" alt="Migration time measurements for SQL Server - click to enlarge" class="no-border" >}}
52+
(*Click the image to enlarge*)
53+
54+
### MySQL
55+
56+
|Associations per table (N)|Many to one|One to one|Many to one, 10 associations in one entity|
57+
|-|-|-|-|
58+
|20K|0.568 s|0.567 s|6.492 s|
59+
|1M|19.9 s|22.8 s|295.1 s|
60+
|20M|473 s|605 s|7318 s|
61+
62+
{{< figure src="/attachments/refguide/runtime/data-storage/association-storage-migration-time/storage-migration-mysql.png" alt="Migration time measurements for MySQL - click to enlarge" class="no-border" >}}
63+
(*Click the image to enlarge*)
64+
65+
### SAP HANA
66+
67+
|Associations per table (N)|Many to one|One to one|Many to one, 10 associations in one entity|
68+
|-|-|-|-|
69+
|20K|0.132 s|0.148 s|1.17 s|
70+
|1M|3.2 s|3 s|18.9 s|
71+
|20M|23.1 s|27.9 s|184.7 s|
72+
73+
{{< figure src="/attachments/refguide/runtime/data-storage/association-storage-migration-time/storage-migration-saphana.png" alt="Migration time measurements for SAP HANA - click to enlarge" class="no-border" >}}
74+
(*Click the image to enlarge*)
482 KB
Loading
206 KB
Loading
224 KB
Loading
227 KB
Loading
217 KB
Loading

0 commit comments

Comments
 (0)