Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Nesta página, descrevemos como ativar o mecanismo colunar do Spanner em um banco de dados, uma tabela ou um índice e acelerar a geração de formatos de arquivo.
Ativar o mecanismo colunar do Spanner
O mecanismo colunar do Spanner é ativado usando uma cláusula SET OPTIONS
com a opção columnar_policy. Você pode aplicar essa opção ao criar ou alterar objetos de esquema DATABASE, TABLE ou INDEX. Os objetos de esquema SEARCH INDEX e VECTOR INDEX nunca estão em formato colunar.
Os níveis mais baixos em uma hierarquia de banco de dados e tabela herdam o columnar_policy do pai. É possível mudar essa configuração em níveis mais baixos.
A opção columnar_policy tem as seguintes flags:
'enabled' ou 'disabled' ativa ou desativa o mecanismo colunar para o objeto de esquema específico.
NULL (padrão) usa a política do mecanismo de colunas do objeto principal, se houver. NULL limpa as configurações anteriores em um objeto de tabela.
Também é possível omitir OPTIONS para herdar o columnar_policy do objeto
pai.
O exemplo a seguir mostra como:
Crie um banco de dados com a política colunar ativada.
Defina uma tabela Singers que herda a política de colunas do banco de dados (omita o columnar_policy = NULL para a opção de tabela).
Defina uma tabela Concerts com a política de colunas explicitamente desativada.
O exemplo a seguir mostra como ativar o mecanismo colunar em um banco de dados chamado Artists e desativá-lo em uma tabela desse banco de dados chamada Museums:
O Spanner gera o formato de arquivo colunar no momento da compactação.
A compactação é um processo em segundo plano que geralmente é distribuído por vários dias, mas pode acontecer antes se o tamanho do banco de dados aumentar muito. Para mais informações, consulte Cobertura colunar ideal.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-17 UTC."],[],[],null,["# Configure Spanner columnar engine\n\n| **Preview\n| --- [Spanner columnar engine](/spanner/docs/columnar-engine)**\n|\n|\n| This feature is subject to the \"Pre-GA Offerings Terms\" in the General Service Terms section\n| of the [Service Specific Terms](/terms/service-terms#1).\n|\n| Pre-GA features are available \"as is\" and might have limited support.\n|\n| For more information, see the\n| [launch stage descriptions](/products#product-launch-stages).\n|\n|\n| For information about access to this\n| release, see the\n| [access request page](https://forms.gle/nE1bAqfHJrqhkStR9).\n\n\n| **PostgreSQL interface note:** The examples in this topic are intended for GoogleSQL-dialect databases. This feature doesn't support PostgreSQL interface.\n\n\u003cbr /\u003e\n\nThis page describes how to enable Spanner columnar engine on a\ndatabase, table, or index, and accelerate file format generation.\n\nEnable Spanner columnar engine\n------------------------------\n\nSpanner columnar engine is enabled using a `SET OPTIONS` clause\nwith the `columnar_policy` option. You can apply this option when you create or\nalter `DATABASE`, `TABLE`, or `INDEX` schema objects. `SEARCH INDEX` and\n`VECTOR INDEX` schema objects are never in columnar format.\n\nLower levels in a database and table hierarchy inherit the `columnar_policy`\nfrom its parent. You can change this setting at lower levels.\n\nThe `columnar_policy` option has the following flags:\n\n- `'enabled'` or `'disabled'` turns the columnar engine on or off for the specific schema object.\n- `NULL` (default) uses the columnar engine policy from the parent object, if one exists. `NULL` clears previous settings on a table object.\n\nYou can also omit `OPTIONS` to inherit the `columnar_policy` from the parent\nobject.\n\nThe following example shows how to:\n\n- Create a database with the columnar policy enabled.\n- Define a `Singers` table that inherits the columnar policy from the database (omit the `columnar_policy = NULL` for the table option).\n- Define a `Concerts` table with the columnar policy explicitly disabled.\n\n CREATE DATABASE Music;\n\n ALTER DATABASE Music SET OPTIONS (columnar_policy = 'enabled');\n\n CREATE TABLE Singers(\n SingerId INT64 NOT NULL,\n FirstName STRING(1024),\n LastName STRING(1024),\n BirthDate DATE,\n Status STRING(1024),\n LastUpdated TIMESTAMP,)\n PRIMARY KEY(SingerId);\n\n CREATE TABLE Concerts(\n VenueId INT64 NOT NULL,\n SingerId INT64 NOT NULL,\n ConcertDate DATE NOT NULL,\n BeginTime TIMESTAMP,\n EndTime TIMESTAMP,)\n PRIMARY KEY(VenueId, SingerId, ConcertDate),\n OPTIONS (columnar_policy = 'disabled');\n\nYou can also use `ALTER TABLE` with the `SET OPTIONS` clause to enable or\ndisable the `columnar_policy` on a table. The following example shows how to\ndisable the policy in the `Singers` table: \n\n ALTER TABLE Singers SET OPTIONS (columnar_policy = 'disabled');\n\n| **Note:** Enabling Spanner columnar engine increases the storage usage of the target database or table (depending on the enabling option used). It's important to ensure that the Spanner instance has sufficient storage capacity to accommodate the increase in storage usage. For more information, see [Database limits](/spanner/quotas#database-limits).\n\nColumnar file format generation\n-------------------------------\n\nSpanner generates the columnar file format at compaction time.\nCompaction is a background process that typically is spread out over multiple\ndays, but it might happen sooner if the size of the database grows\nsubstantially. For more information, see [Optimal columnar coverage](/spanner/docs/columnar-engine#optimal_columnar_coverage).\n| **Note:** You can contact [spanner-columnar-preview@google.com](mailto:spanner-columnar-preview@google.com) to request accelerated generation of columnar format for existing data.\n\nWhat's next\n-----------\n\n- Learn about [columnar engine](/spanner/docs/columnar-engine).\n- Learn how to [query columnar data](/spanner/docs/query-columnar-data).\n- Learn how to [monitor columnar engine](/spanner/docs/monitor-columnar-engine)."]]