How to Explore PostgreSQL Internal Limits

PostgreSQL is a flexible tool for handling many kinds of work, but PostgreSQL also has hidden limits set by how it was built. Those borders are usually invisible when you do database tasks, but they matter a lot when you work with huge schemas, tricky queries, or fancy database features.

Knowing these borders helps developers avoid surprises and build structures that fit inside PostgreSQL limits.

In this blog, we will look at some little-known PostgreSQL limits by trying them out with SQL examples. We will cover identifier length limits, the biggest number of columns a table can hold, how many columns an index can use, how many arguments a function can take, and commands that have special rules for transactions.

So, let’s look at some important limitations of PostgreSQL.

1. Identifier length limit (63 bytes)

Create a table with a table name that contains more than 63 bytes.

CREATE TABLE this_is_a_very_long_table_name_that_is_more_than_sixty_three_characters_long_example
(
    id int
);

Result:

NOTICE:  identifier "this_is_a_very_long_table_name_that_is_more_than_sixty_three_characters_long_example" will be truncated to "this_is_a_very_long_table_name_that_is_more_than_sixty_three_ch"

Now, we can see the length of the table name is trimmed to 63.

Check the name of this table and the length of this table name also.

SELECT relname, length(relname)
FROM pg_class
WHERE relname LIKE 'this_is_a%';

Result:

                             relname                             | length 
-----------------------------------------------------------------+--------
 this_is_a_very_long_table_name_that_is_more_than_sixty_three_ch |     63
(1 row)

This is one of the limits of PostgreSQL based on the table creation.

Now, create the tables with two columns of the same name where the total length is more than 63 bytes, and check the result.

CREATE TABLE test_long_names
(
    this_is_a_very_long_column_name_that_is_more_than_sixty_three_bytes_aaa int,
    this_is_a_very_long_column_name_that_is_more_than_sixty_three_bytes_bbb int
);

Result:

NOTICE:  identifier "this_is_a_very_long_column_name_that_is_more_than_sixty_three_bytes_aaa" will be truncated to "this_is_a_very_long_column_name_that_is_more_than_sixty_three_b"
NOTICE:  identifier "this_is_a_very_long_column_name_that_is_more_than_sixty_three_bytes_bbb" will be truncated to "this_is_a_very_long_column_name_that_is_more_than_sixty_three_b"
ERROR:  column "this_is_a_very_long_column_name_that_is_more_than_sixty_three_b" specified more than once

Now, we can see both names are trimmed to 63 bytes, and we get the error about the same column name.

2. Maximum table columns (1600)

Now, create a table with more than 1600 columns by using the code block below.

DO $$
DECLARE
    cols text;
BEGIN
    SELECT string_agg(format('col%s int', i), ', ')
    INTO cols
    FROM generate_series(1, 1601) AS s(i);
    EXECUTE 'CREATE TABLE test_columns (' || cols || ');';
END $$;

Result:

ERROR:  tables can have at most 1600 columns
CONTEXT:  SQL statement "CREATE TABLE test_columns (col1 int, col2 int, col3 int, col4 int, col5 int, col6 int, col7 int, col8 int, col9 int, col10 int, col11 int, col12 int, col13 int, col14 int, col15 int, col16 int, col17 int, col18 int, col19 int, col20 int, col21 int, col22 int, col23 int, col24 int, col25 int, col26 int, col27 int, col28 int, col29 int, col30 int, col31 int, col32 int, col33 int, col34 int, col35 int, col36 int, col37 int, col38 int, col39 int, col40 int, col41 int, col42 int, col43 int, col44 int, col45 int, col46 int, col47 int, col48 int, col49 int, col50 int, col51 int, col52 int, col53 int, col54 int, col55 int, col56 int, col57 int, col58 int, col59 int, col60 int, col61 int, col62 int, col63 int, col64 int, col65 int, col66 int, col67 int, col68 int, col69 int, col70 int, col71 int, col72 int, col73 int, col74 int, col75 int, col76 int, col77 int, col78 int, col79 int, col80 int, col81 int, col82 int, col83 int, col84 int, col85 int, col86 int, col87 int, col88 int, col89 int, col90 int, col91 int, col92 int, col93 int, col94 int, col95 int, col96 int, col97 int, col98 int, col99 int, col100 int, col101 int, col102 int, col103 int, col104 int, col105 int, col106 int, col107 int, col108 int, col109 int, col110 int, col111 int, col112 int, col113 int, col114 int, col115 int, col116 int, col117 int, col118 int, col119 int, col120 int, col121 int, col122 int, col123 int, col124 int, col125 int, col126 int, col127 int, col128 int, col129 int, col130 int, col131 int, col132 int, col133 int, col134 int, col135 int, col136 int, col137 int, col138 int, col139 int, col140 int, col141 int, col142 int, col143 int, col144 int, col145 int, col14

Here, we can see a clear message about the table column limit. Tables can have at most 1600 columns.

3. Maximum index columns (32)

Now, create a table with 33 columns.

CREATE TABLE test_index_columns
(
    c1 int,
    c2 int,
    c3 int,
    c4 int,
    c5 int,
    c6 int,
    c7 int,
    c8 int,
    c9 int,
    c10 int,
    c11 int,
    c12 int,
    c13 int,
    c14 int,
    c15 int,
    c16 int,
    c17 int,
    c18 int,
    c19 int,
    c20 int,
    c21 int,
    c22 int,
    c23 int,
    c24 int,
    c25 int,
    c26 int,
    c27 int,
    c28 int,
    c29 int,
    c30 int,
    c31 int,
    c32 int,
    c33 int
);

Now, try to create the index by including the 33 columns like this.

CREATE INDEX test_idx
ON test_index_columns
(
c1,c2,c3,c4,c5,c6,c7,c8,
c9,c10,c11,c12,c13,c14,c15,c16,
c17,c18,c19,c20,c21,c22,c23,c24,
c25,c26,c27,c28,c29,c30,c31,c32,
c33
);

Result:

ERROR:  cannot use more than 32 columns in an index

In PostgreSQL, we can only add up to 32 columns in a single index creation.

4. Function argument limit (100)

Now, create a function with more than 100 arguments like this.

CREATE FUNCTION test_function(
a1 int,
a2 int,
a3 int,
a4 int,
a5 int,
a6 int,
a7 int,
a8 int,
a9 int,
a10 int,
a11 int,
a12 int,
a13 int,
a14 int,
a15 int,
a16 int,
a17 int,
a18 int,
a19 int,
a20 int,
a21 int,
a22 int,
a23 int,
a24 int,
a25 int,
a26 int,
a27 int,
a28 int,
a29 int,
a30 int,
a31 int,
a32 int,
a33 int,
a34 int,
a35 int,
a36 int,
a37 int,
a38 int,
a39 int,
a40 int,
a41 int,
a42 int,
a43 int,
a44 int,
a45 int,
a46 int,
a47 int,
a48 int,
a49 int,
a50 int,
a51 int,
a52 int,
a53 int,
a54 int,
a55 int,
a56 int,
a57 int,
a58 int,
a59 int,
a60 int,
a61 int,
a62 int,
a63 int,
a64 int,
a65 int,
a66 int,
a67 int,
a68 int,
a69 int,
a70 int,
a71 int,
a72 int,
a73 int,
a74 int,
a75 int,
a76 int,
a77 int,
a78 int,
a79 int,
a80 int,
a81 int,
a82 int,
a83 int,
a84 int,
a85 int,
a86 int,
a87 int,
a88 int,
a89 int,
a90 int,
a91 int,
a92 int,
a93 int,
a94 int,
a95 int,
a96 int,
a97 int,
a98 int,
a99 int,
a100 int,
a101 int
)
RETURNS int
AS $$
SELECT 1;
$$ LANGUAGE SQL;

Result:

ERROR:  functions cannot have more than 100 arguments

Now, we can see a limit of 100 for adding arguments in the function creation.

5. CREATE INDEX CONCURRENTLY cannot run inside a transaction

Now, create a simple table.

CREATE TABLE test_table(    id int);

Inside a transaction, try to create the index concurrently and check the result.

BEGIN;postgres=*# CREATE INDEX CONCURRENTLY test_idxON test_table(id);

Result:

BEGIN;
postgres=*# CREATE INDEX CONCURRENTLY test_idx
ON test_table(id);

Now, we can see a clear error message indicating that we cannot run the CREATE INDEX CONCURRENTLY command inside a transaction.

6. CREATE INDEX CONCURRENTLY on partitioned table

Create a partitioned table and partition a column like the example below.

CREATE TABLE orders
(
    id int,
    created date
)
PARTITION BY RANGE(created);

Create a sample child partition table also like this.

CREATE TABLE orders_2026
PARTITION OF orders
FOR VALUES FROM ('2026-01-01')
TO ('2027-01-01');

Now, try to create the index concurrently on the parent partitioned table.

CREATE INDEX CONCURRENTLY orders_idx
ON orders(created);

Result:

ERROR:  cannot create index on partitioned table "orders" concurrently

Now, we can see the clear error message that we cannot create an index concurrently on the partitioned table.

7. Cannot create a database inside a transaction

Now, inside a transaction, try to create a database and check its result.

BEGIN;
postgres=*# CREATE DATABASE testdb;

Result:

ERROR:  CREATE DATABASE cannot run inside a transaction block

We cannot create a database inside a transaction.

PostgreSQL can handle different kinds of database needs, but it does have limits. These limits come from how the system is built. Knowing what these limits are helps you avoid problems and make choices when designing your database.

The examples in this blog show how PostgreSQL clearly tells you when you hit a limit. You might get a message saying a long name was cut off, that a table has too many columns, or that a certain command won’t work inside a transaction. These error messages are useful because they show how the system works under the hood. When you understand them, you can build more stable database designs.

WhatsApp