[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-09-03。"],[[["\u003cp\u003eYou can manually manage the content of the columnar engine's column store by adding or removing columns from tables and materialized views.\u003c/p\u003e\n"],["\u003cp\u003eTo add or remove columns, you can either update the \u003ccode\u003egoogle_columnar_engine.relations\u003c/code\u003e database flag or use specific SQL functions.\u003c/p\u003e\n"],["\u003cp\u003eAdding columns via the database flag will persist the changes across instance restarts, while using SQL functions only manages columns in the connected node and does not persist after restart.\u003c/p\u003e\n"],["\u003cp\u003eConsider factors like column store size and workload patterns when selecting columns, with frequently scanned large tables or views and their non-unique indexes being good candidates for the column store.\u003c/p\u003e\n"]]],[],null,["# Manage column store content manually\n\nThis page describes how to manage the content of the columnar engine's\ncolumn store by manually adding and removing columns.\n\nBased on your workload, you can manually add columns to the column store or drop\nsome or all of the columns of a table or a materialized view from the column\nstore. Query evaluation automatically uses the stored columnar data to answer\nqueries.\n\nWhen choosing which tables, materialized views and columns to add to the column store, consider both the size of the column store and the shape of the workload. Good candidates for selection include large tables or views that are frequently scanned. Within these tables or views,\nidentify any large non-unique indexes used by the OLAP workload. You can add\nthese indexes' columns to the column store and potentially drop the indexes,\nthereby eliminating the performance cost associated with their maintenance on\nthe primary instance.\n\nUse one of the following methods to manage the content of the columnar engine's\ncolumn store:\n\n- [Manage column store content by updating database flags](#manage-relations)\n- [Manage column store content using SQL functions](#manage-sql)\n\nSee [What data you can add to the column\nstore](/alloydb/docs/columnar-engine/about#limitations) for information\nabout what data types and data sources you can use when adding tables, columns, and materialized views to the column store.\n\n\nBefore you begin\n----------------\n\n- You must have one of these IAM roles in the Google Cloud project you are using:\n - `roles/alloydb.admin` (the AlloyDB Admin predefined IAM role)\n - `roles/owner` (the Owner basic IAM role)\n - `roles/editor` (the Editor basic IAM role)\n\n If you don't have any of these roles, contact your Organization Administrator to request\n access.\n\n\u003cbr /\u003e\n\nManage column store content by updating database flags\n------------------------------------------------------\n\nYou can manage column store content manually by updating the\n`google_columnar_engine.relations` database flag. The flag has a single\nvalue that specifies all of your column store's data sources. During the\nrestart, columns specified in this flag are automatically populated into the\ncolumn store.\n\nYou can use this flag together with [auto-columnarization](/alloydb/docs/columnar-engine/manage-content-recommendations). If the\ncolumnar engine has memory available after populating the columns you\nspecify through the `google_columnar_engine.relations` flag, then\nauto-columnarization adds further columns to the column store, as\nneeded.\n\nFor more information on setting an instance's database flags using\neither Google Cloud CLI or the Google Cloud console, see [Configure an\ninstance's database\nflags](/alloydb/docs/instance-configure-database-flags).\n\n### Add columns using flags\n\nTo add columns to the column store, define an instance's\n`google_columnar_engine.relations` flag. Set its value to a comma-separated list\nof items, with each item specifying a list of columns to include from a specific\ntable, in this format: \n\n \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eSCHEMA_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e(\u003cvar translate=\"no\"\u003eCOLUMN_LIST\u003c/var\u003e)\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e: the database containing the columns to add\n to the column store.\n\n- \u003cvar translate=\"no\"\u003eSCHEMA_NAME\u003c/var\u003e: the schema identifying the tables or the\n materialized views to add to the column store---for example, `public`.\n\n- \u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e: the table or the materialized view containing\n the columns to add to the column store.\n\n- \u003cvar translate=\"no\"\u003eCOLUMN_LIST\u003c/var\u003e: a comma-separated list of the\n columns to add to the column store.\n\nTo add all of one table's or one materialized view's columns, omit the column\nlist: \n\n \u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eSCHEMA_NAME\u003c/var\u003e.\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e\n\nFor more information on setting the database flags on an instance, see [Configure an instance's\ndatabase flags](/alloydb/docs/instance-configure-database-flags).\n\n#### A note about command-line syntax\n\nIf you use the Google Cloud CLI to set the `google_columnar_engine.relations` flag, then you must use [alternate delimiter syntax](https://cloud.google.com/sdk/gcloud/reference/topic/escaping) to separate the database flags that you set. This is because the column list is comma-separated, requiring you to use a non-comma character when specifying flags within the same command-line argument.\n\nThe following example demonstrates using the gcloud CLI to add two columns in the `public` schema to the column store. The example sets a separate\nflag to enable the columnar engine, because using [the\n`gcloud alloydb instance update` command](/sdk/gcloud/reference/alloydb/instances/update) to set any database flag must also set all other database flags that you want to have non-default values, even if they're already set.\n**Caution:** Running this example unsets all database flags from the instance except for the flags that it specifies. \n\n gcloud alloydb instances update \u003cvar translate=\"no\"\u003eINSTANCE_NAME\u003c/var\u003e \\\n --database-flags=^:^\\\n google_columnar_engine.relations='\u003cvar translate=\"no\"\u003eDATABASE_NAME\u003c/var\u003e.public.\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e(\u003cvar translate=\"no\"\u003eCOLUMN_1\u003c/var\u003e,\u003cvar translate=\"no\"\u003eCOLUMN_2\u003c/var\u003e)'\\\n :google_columnar_engine.enabled=on\\\n [:\u003cvar translate=\"no\"\u003eFLAG_3\u003c/var\u003e=\u003cvar translate=\"no\"\u003eVALUE_3\u003c/var\u003e ...] \\\n --region=\u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e \\\n --cluster=\u003cvar translate=\"no\"\u003eCLUSTER_ID\u003c/var\u003e\n\n### Drop columns using flags\n\nTo drop columns from the column store, set a new value for the\n`google_columnar_engine.relations` flag described in the previous section,\nleaving out the columns that you wish to drop.\n\nTo drop all of the columns from the column store, unset the\n`google_columnar_engine.relations` flag from your instance.\n\nFor more information on setting database flags on an instance, see [Configure an instance's\ndatabase flags](/alloydb/docs/instance-configure-database-flags).\n\nManage column store content using SQL functions\n-----------------------------------------------\n\nYou can manage column store content manually by using SQL functions.\n\n### Add columns using SQL functions\n\nRun the `google_columnar_engine_add` SQL function to add columns\nto the column store.\n\nThis method adds the specified columns to the column store and manages the columns\nin the connected node only. The new columns do not persist within the store across\ninstance restarts.\n\nThis method does not change the\n[`google_columnar_engine.relations`](#manage-relations)\ndatabase flag. [Auto\ncolumnarization](/alloydb/docs/columnar-engine/manage-content-recommendations)\ndoes not consider columns added by this SQL function. \n\n### psql Client\n\n```\nSELECT google_columnar_engine_add(\n relation =\u003e 'TABLE_NAME',\n columns =\u003e 'COLUMN_LIST'\n);\n```\n\nReplace the following:\n- '\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e': A string containing the name of the table or the materialized view. If the table or the view is in a schema other than `public`, specify the name of the schema, a dot, and the name of the table or the view; for example, `'myschema.mytable'`.\n- '\u003cvar translate=\"no\"\u003eCOLUMN_LIST\u003c/var\u003e': A string containing a comma-separated, case-sensitive list of the names of the columns you want to add. If you want to add all of the table's or the materialized view's columns to the column store, omit this parameter.\n\n### Drop columns using SQL functions\n\nRun the `google_columnar_engine_drop` SQL function as follows: \n\n### psql Client\n\n```\nSELECT google_columnar_engine_drop(\n relation =\u003e 'TABLE_NAME',\n columns =\u003e 'COLUMN_LIST'\n);\n```\nReplace the following:\n\n- '\u003cvar translate=\"no\"\u003eTABLE_NAME\u003c/var\u003e': A string containing the name of the table or the materialized view. If the table or the view is in a schema other than `public`, specify the name of the schema, a dot, and the name of the table or the view; for example, `'myschema.mytable'`.\n- '\u003cvar translate=\"no\"\u003eCOLUMN_LIST\u003c/var\u003e': A string containing a comma-separated, case-sensitive list of the names of the columns you want to add. If you want to add all of the table's or the materialized view's columns to the column store, omit this parameter.\n\nYou can use the `google_columnar_engine_drop` function to remove columns added\nby editing the `google_columnar_engine.relations` database flag. However, when\nyou do so, those columns will be added back to the columnar store when the\ninstance is restarted."]]