[Django] #34843: Feature request: Support postgres table storage options

10 views
Skip to first unread message

Django

unread,
Sep 15, 2023, 10:40:48 AM9/15/23
to django-...@googlegroups.com
#34843: Feature request: Support postgres table storage options
-------------------------------------+-------------------------------------
Reporter: Anton- | Owner: nobody
Shutik |
Type: New | Status: new
feature |
Component: | Version: 3.2
Migrations | Keywords: postgres,
Severity: Normal | autovacuum, storage options, django
Triage Stage: | migrations
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
There is a list of storage options
(https://www.postgresql.org/docs/current/sql-createtable.html#SQL-
CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table
in postgres database. So, since django manages database schema, it would
be nice to extend it to support these storage options.

It might look like:

{{{
class MyModel(db.Models):

# fields go here

class Meta:
storage_options = {
"autovacuum_vacuum_scale_factor": 0.01,
"autovacuum_vacuum_threshold": 1000
}

}}}

and that would produce migration which eventually will run sql like this:

`CREATE TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
autovacuum_vacuum_threshold = 1000);`


For now it could be done with `RunSQL(sql='ALTER TABLE .... WITH (...);')`
migration, but it would be better to have the settings on the model class
itself for better visibility and managed by django.

What do you think ?

--
Ticket URL: <https://code.djangoproject.com/ticket/34843>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 15, 2023, 10:43:24 AM9/15/23
to django-...@googlegroups.com
#34843: Feature request: Support postgres table storage options
-------------------------------------+-------------------------------------
Reporter: Anton-Shutik | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Resolution:
Keywords: postgres, | Triage Stage:
autovacuum, storage options, | Unreviewed
django migrations |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Anton-Shutik:

Old description:

> There is a list of storage options
> (https://www.postgresql.org/docs/current/sql-createtable.html#SQL-
> CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table
> in postgres database. So, since django manages database schema, it would
> be nice to extend it to support these storage options.
>
> It might look like:
>
> {{{
> class MyModel(db.Models):
>
> # fields go here
>
> class Meta:
> storage_options = {
> "autovacuum_vacuum_scale_factor": 0.01,
> "autovacuum_vacuum_threshold": 1000
> }
>
> }}}
>
> and that would produce migration which eventually will run sql like this:
>
> `CREATE TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
> autovacuum_vacuum_threshold = 1000);`
>

> For now it could be done with `RunSQL(sql='ALTER TABLE .... WITH
> (...);')` migration, but it would be better to have the settings on the
> model class itself for better visibility and managed by django.
>
> What do you think ?

New description:

There is a list of storage options
(https://www.postgresql.org/docs/current/sql-createtable.html#SQL-
CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table
in postgres database. So, since django manages database schema, it would
be nice to extend it to support these storage options.

It might look like:

{{{
class MyModel(models.Model):

# fields go here

class Meta:
storage_options = {
"autovacuum_vacuum_scale_factor": 0.01,
"autovacuum_vacuum_threshold": 1000
}

}}}

and that would produce migration which eventually will run sql like this:

`CREATE TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
autovacuum_vacuum_threshold = 1000);`


For now it could be done with `RunSQL(sql='ALTER TABLE .... WITH (...);')`
migration, but it would be better to have the settings on the model class
itself for better visibility and managed by django.

What do you think ?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34843#comment:1>

Django

unread,
Sep 15, 2023, 10:55:46 AM9/15/23
to django-...@googlegroups.com
#34843: Feature request: Support postgres table storage options
-------------------------------------+-------------------------------------
Reporter: Anton-Shutik | Owner: nobody
Type: New feature | Status: new
Component: Migrations | Version: 3.2
Severity: Normal | Resolution:
Keywords: postgres, | Triage Stage:
autovacuum, storage options, | Unreviewed
django migrations |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by Anton-Shutik:

Old description:

> There is a list of storage options
> (https://www.postgresql.org/docs/current/sql-createtable.html#SQL-
> CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table
> in postgres database. So, since django manages database schema, it would
> be nice to extend it to support these storage options.
>
> It might look like:
>
> {{{

New description:

It might look like:

{{{
class MyModel(models.Model):

# fields go here

}}}

`CREATE/ALTER TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
autovacuum_vacuum_threshold = 1000);`


For now it could be done with `RunSQL(sql='ALTER TABLE .... WITH (...);')`
migration, but it would be better to have the settings on the model class
itself for better visibility and managed by django.

What do you think ?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34843#comment:2>

Django

unread,
Sep 15, 2023, 10:56:09 AM9/15/23
to django-...@googlegroups.com

Old description:

> `CREATE/ALTER TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
> autovacuum_vacuum_threshold = 1000);`
>

> For now it could be done with `RunSQL(sql='ALTER TABLE .... WITH
> (...);')` migration, but it would be better to have the settings on the
> model class itself for better visibility and managed by django.
>
> What do you think ?

New description:

There is a list of storage options
(https://www.postgresql.org/docs/current/sql-createtable.html#SQL-
CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table
in postgres database. So, since django manages database schema, it would
be nice to extend it to support these storage options.

It might look like:

{{{
class MyModel(models.Model):

# fields go here

class Meta:
storage_options = {
"autovacuum_vacuum_scale_factor": 0.01,
"autovacuum_vacuum_threshold": 1000
}

}}}

and that would produce migration which eventually will run sql like this:

`CREATE/ALTER TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01,
autovacuum_vacuum_threshold = 1000);`


For now it could be done with `RunSQL(sql='CREATE/ALTER TABLE .... WITH


(...);')` migration, but it would be better to have the settings on the
model class itself for better visibility and managed by django.

What do you think ?

--

--
Ticket URL: <https://code.djangoproject.com/ticket/34843#comment:3>

Django

unread,
Sep 15, 2023, 12:13:57 PM9/15/23
to django-...@googlegroups.com
#34843: Feature request: Support postgres table storage options
-------------------------------------+-------------------------------------
Reporter: Anton Shutik | Owner: nobody
Type: New feature | Status: closed
Component: Migrations | Version: 3.2
Severity: Normal | Resolution: wontfix

Keywords: postgres, | Triage Stage:
autovacuum, storage options, | Unreviewed
django migrations |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Sanders):

* status: new => closed
* resolution: => wontfix


Comment:

Hi Anton,

Thanks for the idea, though all feature requests should be discussed on
the Django forum first where it'll reach a wider audience:
https://code.djangoproject.com/wiki/DevelopersMailingList

Having said that, it may be unlikely to be accepted since developers can
add their own migration to set these parameters after table creation.
Additionally it is likely to be considered outside the scope of what
Django is responsible for.

Thanks!

--
Ticket URL: <https://code.djangoproject.com/ticket/34843#comment:4>

Reply all
Reply to author
Forward
0 new messages