Opened 18 months ago

Last modified 18 months ago

#26506 new New feature

Implement support for TABLESAMPLE

Reported by: Nick Pope Owned by: nobody
Component: Database layer (models, ORM) Version: master
Severity: Normal Keywords: tablesample
Cc: pembo13@… Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

PostgreSQL 9.5 added support for the TABLESAMPLE feature from the SQL:2003 standard. It would be useful to add support for this to Django.

For PostgreSQL it would also be good to support the custom tsm_system_rows and tsm_system_time extensions to provide SYSTEM_ROWS and SYSTEM_TIME in addition to BERNOULLI and SYSTEM defined in the standard.

Note that TABLESAMPLE can also be used to update or delete only a sample of rows.

I suggest adding .tablesample(method, value[, seed]) to QuerySet where:

  • method is one of bernoulli, system, rows or time,
  • value is the percentage, count or time argument to pass,
  • seed is the value to use for the REPEATABLE option.

Note that seed should not be allowed with rows or time methods -- see links to extension documentation below.

Minimum versions for supported databases:

  • PostgreSQL 9.5
  • Microsoft SQL Server 2005 -- only supports system (percent) and rows (count)

References:

Change History (2)

comment:1 Changed 18 months ago by Tim Graham

Triage Stage: UnreviewedAccepted

Before doing any coding, please create a thread on the DevelopersMailingList to get feedback on the proposed APIs and add a link to it in this ticket.

comment:2 Changed 18 months ago by Arthur Pemberton

Cc: pembo13@… added
Note: See TracTickets for help on using tickets.
Back to Top