---
title: "Tablespaces"
version: 1.9
locale: id
source: https://docs.djangoproject.com/id/1.9/topics/db/tablespaces/
canonical: https://djangodocs.dev/id/1.9/topics/db/tablespaces/
---
# Tablespaces

A common paradigm for optimizing performance in database systems is the use of
[tablespaces](https://en.wikipedia.org/wiki/Tablespace) to organize disk layout.

> **Warning**
>
> Django tidak membuat tablespace untuk anda. Silahkan mengacu ke dokumentasi mesis basisdata anda untuk rincian di membuat dan mengelola tablespace.

## Mengumumkan tablespace untuk table

A tablespace can be specified for the table generated by a model by supplying
the [`db_tablespace`](/id/1.9/ref/models/options/#django.db.models.Options.db_tablespace) option inside the model's
`class Meta`. This option also affects tables automatically created for
[`ManyToManyField`](/id/1.9/ref/models/fields/#django.db.models.ManyToManyField)s in the model.

You can use the [`DEFAULT_TABLESPACE`](/id/1.9/ref/settings/#std-setting-DEFAULT_TABLESPACE) setting to specify a default value
for [`db_tablespace`](/id/1.9/ref/models/options/#django.db.models.Options.db_tablespace). This is useful for setting
a tablespace for the built-in Django apps and other applications whose code you
cannot control.

## Mengumumkan tablespace untuk indeks

You can pass the [`db_tablespace`](/id/1.9/ref/models/fields/#django.db.models.Field.db_tablespace) option to a
`Field` constructor to specify an alternate tablespace for the `Field`’s
column index. If no index would be created for the column, the option is
ignored.

You can use the [`DEFAULT_INDEX_TABLESPACE`](/id/1.9/ref/settings/#std-setting-DEFAULT_INDEX_TABLESPACE) setting to specify
a default value for [`db_tablespace`](/id/1.9/ref/models/fields/#django.db.models.Field.db_tablespace).

If [`db_tablespace`](/id/1.9/ref/models/fields/#django.db.models.Field.db_tablespace) isn't specified and you didn't
set [`DEFAULT_INDEX_TABLESPACE`](/id/1.9/ref/settings/#std-setting-DEFAULT_INDEX_TABLESPACE), the index is created in the same
tablespace as the tables.

## Sebuah contoh

```python
class TablespaceExample(models.Model):
    name = models.CharField(max_length=30, db_index=True, db_tablespace="indexes")
    data = models.CharField(max_length=255, db_index=True)
    edges = models.ManyToManyField(to="self", db_tablespace="indexes")

    class Meta:
        db_tablespace = "tables"
```

In this example, the tables generated by the `TablespaceExample` model (i.e.
the model table and the many-to-many table) would be stored in the `tables`
tablespace. The index for the name field and the indexes on the many-to-many
table would be stored in the `indexes` tablespace. The `data` field would
also generate an index, but no tablespace for it is specified, so it would be
stored in the model tablespace `tables` by default.

## Dukungan basisdata

PostgreSQL dan Oracle mendukung tablespace. SQLite dan MySQL tidak.

When you use a backend that lacks support for tablespaces, Django ignores all
tablespace-related options.
