ERROR: Cannot create ScaNN index with empty table. Once the table is populated
with data, create the index. See documentation to bypass this validation.
ERROR: Cannot create ScaNN index on parent partition table. Create ScaNN
indexes on the child tables instead. See documentation to bypass this
validation.
[[["易于理解","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-08-25。"],[[["\u003cp\u003eThis document outlines potential errors encountered when creating a \u003ccode\u003eScaNN\u003c/code\u003e index, including issues with empty tables, insufficient data rows, and attempts to index parent partition tables.\u003c/p\u003e\n"],["\u003cp\u003eA common fix for issues when generating a \u003ccode\u003eScaNN\u003c/code\u003e index is to ensure that the table contains an adequate amount of data, especially embedding vectors.\u003c/p\u003e\n"],["\u003cp\u003eCreating a \u003ccode\u003eScaNN\u003c/code\u003e index on an empty table or truncating a table with an existing \u003ccode\u003eScaNN\u003c/code\u003e index will result in an error, and the table needs to be populated before indexing.\u003c/p\u003e\n"],["\u003cp\u003eAttempting to create a \u003ccode\u003eScaNN\u003c/code\u003e index on a parent partition table is not allowed; instead, indexes should be created on the individual child partition tables.\u003c/p\u003e\n"],["\u003cp\u003eWhile it is possible to force the creation of a \u003ccode\u003eScaNN\u003c/code\u003e index and suppress errors by setting \u003ccode\u003escann.allow_blocked_operations\u003c/code\u003e to \u003ccode\u003etrue\u003c/code\u003e and assigning \u003ccode\u003eSUPERUSER\u003c/code\u003e privileges, this can lead to poor index performance and slower write speeds.\u003c/p\u003e\n"]]],[],null,["# Troubleshoot ScaNN index errors\n\nThis document describes errors you might encounter when you generate a `ScaNN` index. Examples of errors and recommended fixes are also provided.\n\n\u003cbr /\u003e\n\nList of errors\n--------------\n\nThe following a list of errors that are generated when you try to create a\n`ScaNN` index. You can disable generation of these errors and continue to generate\nthe index. For more information, see [Enforce index creation and suppress errors](#enforce-index-creation).\n\n### ERROR: Cannot create ScaNN index with empty table\n\n#### Error message\n\nWhen you try to generate an index on a table with no data or try to truncate a\ntable with a `ScaNN` index generated on it, the following error occurs:\n\n`ERROR: Cannot create ScaNN index with empty table. Once the table is populated\nwith data, create the index. See documentation to bypass this validation.`\n\n#### Sample queries that cause the error\n\n- Query Example A\n\n create table t1 (a INT, b VECTOR(512));\n CREATE TABLE\n create index on t1 using ScaNN(b cosine) with (num_leaves = 10, quantizer = 'sq8');\n\n- Query Example B\n\n truncate t1;\n\n#### Recommended fix\n\nMake sure that your table is populated with embedding vectors before you generate a `ScaNN` index.\n\n### ERROR: Cannot create ScaNN index\n\n#### Error message\n\nWhen you try to generate an index on a table with few rows populated, the\nfollowing error occurs:\n\n`Cannot create ScaNN index, error: INVALID_ARGUMENT: Number of row (5) must be\nlarger than (1000).`\n\n#### Sample query that causes the error\n\n create table t1 (a INT, b VECTOR(512));\n CREATE TABLE\n insert into t1 select (random()*1e9)::int, random_vector(512) from generate_series(1, 5);\n INSERT 0 5\n create index on t1 using scann(b cosine) with (num_leaves = 100, quantizer = 'sq8');\n\n#### Recommended fix\n\nEnsure that your table is populated with embedding vectors before you generate a\n`ScaNN` index. We recommend that the number of rows in the table are greater\nthan the value defined in the `num_leaves` parameter.\n\n### ERROR: Cannot create ScaNN index on parent partition table.\n\n#### Error message\n\nIf you have created partitioned tables from a parent table, then creating a\nScaNN index on the parent table generates the following error:\n\n`ERROR: Cannot create ScaNN index on parent partition table. Create ScaNN\nindexes on the child tables instead. See documentation to bypass this\nvalidation.`\n\n#### Sample query that causes the error\n\n create table t1 (a INT, b VECTOR(512)) partition by range(a);\n CREATE TABLE\n CREATE TABLE t1_one_ten PARTITION of t1 for values from (1) to (10);\n CREATE TABLE\n insert into t1_one_ten select (random()*1e9)::int, random_vector(512) from generate_series(1, 100);\n INSERT 0 100\n CREATE TABLE t1_eleven_twenty PARTITION of t1 for values from (11) to (20);\n CREATE TABLE\n insert into t1_eleven_twenty select (random()*1e9)::int, random_vector(512) from generate_series(1, 100);\n INSERT 0 100\n create index on t1 using scann(b cosine) with (num_leaves = 10, quantizer = 'sq8');\n\n#### Recommended fix\n\nYou can't generate a `ScaNN` index on the parent table of a partitioned table.\nYou must generate the `ScaNN` indexes on the partitioned table.\n\nEnforce index creation and suppress errors\n------------------------------------------\n\nYou can enforce AlloyDB to generate an index and suppress errors. Before\nallowing index generation with this method, consider the following implications:\n\n- Since the index is trained on less or no data, centroids learn on zero data leading to bad recall.\n- The write performance to the database might also be slow.\n\nTo force index generation, complete the following:\n\n1. Set the `scann.allow_blocked_operations creation` session-level parameter\n to `true` on the database:\n\n SET scann.allow_blocked_operations = true;\n\n2. Assign the `SUPERUSER` privilege to the user that will run these queries on the database:\n\n CREATE USER \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eUSER_NAME\u003c/span\u003e\u003c/var\u003e WITH SUPERUSER PASSWORD \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003ePASSWORD\u003c/span\u003e\u003c/var\u003e;\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eUSER_NAME\u003c/var\u003e: the name of the user you want to grant the privilege to.\n - \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e: the password of the user."]]