-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4245ab5
commit 2ba074f
Showing
11 changed files
with
279 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Table partitioning | ||
================== | ||
|
||
Table partitioning is a division of one table into several tables, called partitions, which still | ||
represent original table. This is usually done for manageability, performance or availability reasons. | ||
If you are unsure whether you need partitioning or not, then you almost certainly don't need it. | ||
|
||
To use this feature, define the model as usual and create a table for it in the database using the | ||
usual tools that your ORM provides. After the table was created, this feature can be installed into | ||
the model as the following: | ||
|
||
.. code-block:: python | ||
import architect | ||
@architect.install('partition', **options) | ||
class Model(object): | ||
pass | ||
where ``options`` are: | ||
|
||
- ``type`` (required). Partition type, e.g. ``range``, ``list`` etc | ||
- ``subtype`` (required). Partition subtype, e.g. ``date``, ``integer`` etc | ||
- ``constraint`` (required). What data fits into partition, e.g. ``day``, ``5`` (every 5 items) etc | ||
- ``column`` (required). Column, which value determines which partition record belongs to | ||
- ``dsn`` (optional). Data Source Name in the form of dialect://user:pass@host/database. Currently needed | ||
only for SQLAlchemy ORM. | ||
|
||
Above options can take different values depending on the database type because different databases support | ||
different partition types, subtypes etc. To find out which values can be set for the above options choose | ||
the database type which you currently use from the list below: | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
|
||
postgresql | ||
mysql | ||
|
||
.. note:: | ||
|
||
Using this feature with a Django ORM, run the following command before moving to next step, | ||
substituting ``mysite.settings`` to the real path of the Django settings module: | ||
|
||
.. code-block:: bash | ||
$ export DJANGO_SETTINGS_MODULE=mysite.settings | ||
After the feature has been installed into the model, run the following console command: | ||
|
||
.. code-block:: bash | ||
$ architect partition --module path.to.the.model.module | ||
That's it. Now, when a new record will be inserted, a value from column, specified in the ``column`` | ||
option will be used to determine into what partition the data should be saved. Keep in mind that if | ||
new partitioned models are added or any settings are changed in existing partitioned models, the | ||
partition command should be rerun, otherwise the database won't know about this changes. | ||
|
||
.. raw:: html | ||
|
||
<h2 id="api"> | ||
API | ||
<a class="headerlink" href="#api" title="Permalink to this headline">¶</a> | ||
</h2> | ||
|
||
After the installation partition feature can be accessed via ``Model.architect.partition``, though it | ||
usually doesn't need to be accessed directly because everything is done automatically. It provides the | ||
following methods: | ||
|
||
.. autoattribute-name-only:: architect.orms.bases.BasePartitionFeature.model_meta | ||
.. automethod-name-only:: architect.orms.bases.BasePartitionFeature.get_partition | ||
|
||
This object provides the following methods: | ||
|
||
.. automethod-name-only:: architect.databases.bases.BasePartition.prepare | ||
.. automethod-name-only:: architect.databases.bases.BasePartition.create | ||
.. automethod-name-only:: architect.databases.bases.BasePartition.exists |
Oops, something went wrong.