Skip to content

TCS: truncate table #5434

@lenkis

Description

@lenkis

Related dev. resources:

Product: TCS
Since: 1.2
Audience/target: admins, end users (finops)
Root document: https://www.tarantool.io/ru/column-store/doc/latest/
SME: @ Galiev-Ruslan

Details

Document TRUNCATE syntax + limitations

Don't see truncate in DF doc: https://datafusion.apache.org/user-guide/sql/

Google AI says:

Apache DataFusion, as a query engine, supports the TRUNCATE TABLE SQL statement for removing all rows from a table. This operation is generally faster than a DELETE statement without a WHERE clause, especially for large tables, because it typically deallocates the entire data space of the table rather than deleting row by row.

Syntax:
The basic syntax for truncating a table in DataFusion, similar to standard SQL, is:

TRUNCATE TABLE table_name;

Key Characteristics and Considerations:

  • Removes all rows: TRUNCATE TABLE removes all data from the specified table.
  • Retains table structure: Unlike DROP TABLE, TRUNCATE TABLE preserves the table's schema, including its columns, constraints (with some exceptions), and indexes.
  • Performance: It is generally more efficient than DELETE FROM table_name; for emptying an entire table, as it avoids logging individual row deletions.
  • Transactionality: The behavior regarding transactions can vary depending on the underlying storage system and DataFusion's integration.
  • Foreign Key Constraints: TRUNCATE TABLE may fail if the table has foreign key constraints referencing it from other tables, especially in certain database systems.
  • No WHERE clause: TRUNCATE TABLE does not support a WHERE clause; it always operates on the entire table.

Example:
To remove all data from a table named my_data, you would execute the following SQL query in DataFusion:

TRUNCATE TABLE my_data;

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions