Feature #5109
Optmize Cyclades DB queries
Status: | New | Start date: | 02/19/2014 | |
---|---|---|---|---|
Priority: | Medium | Due date: | ||
Assignee: | Christos Stavrakakis | % Done: | 0% |
|
Category: | - | Spent time: | - | |
Target version: | 0.16 |
Description
Current DB schema of Cyclades is normalized in order to avoid
redundancy of data between tables, define clear relationships
between entities and make easier the update operations.
However, this normalized schema may result in common API calls
resulting in complex queries, using joins and arrays.
There are cases, were some small denormalization of the DB schema
may cause significant performance boost, like the following:
1) Store the IDs of the subnets that are are associated with a
network in the comma-separated field in the network. The IDs
of the subnet are needed for the /networks API call.
2) Store the description of the allocation pools of a subnet
in a JSON field in the subnet. The description of the allocation
pools are needed for the /subnets API call.
3) Store the address and subnet of IPs of the port in a JSON field
insided the port, needed for /ports and /servers API calls.
Associated revisions
cyclades: Add list of subnet IDs to network model
Extend Network model with 'subnet_ids' attribute. This attribute is a
list with the IDs of the subnet that belong to this network and is
stored in DB as a comma seperated list of integers.
This information is already contained in the Subnet model. However, we
also store it in the DB model to make GET /networks API call faster by
avoiding use of 'prefetch_related'.
This commit also extends 'create_subnet' function to update the
network's 'subnet_ids' field.
Refs #5109
cyclades: Add 'public' attribute to ports
Extend ports (NetworkInterface model) with 'public' attribute, to
indicate that the port is connected to a public network without getting
the network from the DB. Add corresponding DB migration and update the
DB models factory.
Refs: #5109