Thread: org.postgresql.util.PSQLException: ERROR: index row requires more memory than default(8191)

I am trying to use PostgreSQL in our existing project to improve the
performance and make it fiendly with JSON. I have done some research on the
PostgerSQL and trying to integrate it into our application. But I am facing
some problem when I tried to insert the large json document into the table.
It is working with small set of json document but fails with the large data.
The following is the error dispalyed in the console when inserting the data.

org.postgresql.util.PSQLException: ERROR: index row requires 11936 bytes,
maximum size is 8191at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)at
org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)at
org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:321)at
org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:297)at
com.practice.PracticeClass.main(PracticeClass.java:28)
org.postgresql.util.PSQLException: ERROR: index row requires 11936 bytes,
maximum size is 8191

In the above error, It is saying memory is not sufficient to create an
index. I am new to this Postgres. I am not creating any index when inserting
the json document. I am thinking it is internally creating an index for the
column.

Table creation: Create table sample(id serial, info jsonb);

Could any tell me how to resolve this error or how to configure to increase
the memory to insert large data.



--
View this message in context:
http://postgresql.nabble.com/org-postgresql-util-PSQLException-ERROR-index-row-requires-more-memory-than-default-8191-tp5899379.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.



On Mon, Apr 18, 2016 at 11:05 PM, msn <pioneer.suri@gmail.com> wrote:
I am trying to use PostgreSQL in our existing project to improve the
performance and make it fiendly with JSON. I have done some research on the
PostgerSQL and trying to integrate it into our application. But I am facing
some problem when I tried to insert the large json document into the table.
It is working with small set of json document but fails with the large data.
The following is the error dispalyed in the console when inserting the data.

org.postgresql.util.PSQLException: ERROR: index row requires 11936 bytes,
maximum size is 8191
        at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2284)
        at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2003)
        at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:200)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:424)
        at org.postgresql.jdbc.PgStatement.executeWithFlags(PgStatement.java:321)
        at org.postgresql.jdbc.PgStatement.executeUpdate(PgStatement.java:297)
        at com.practice.PracticeClass.main(PracticeClass.java:28)
org.postgresql.util.PSQLException: ERROR: index row requires 11936 bytes,
maximum size is 8191

In the above error, It is saying memory is not sufficient to create an
index. I am new to this Postgres. I am not creating any index when inserting
the json document. I am thinking it is internally creating an index for the
column.

Table creation: Create table sample(id serial, info jsonb);

Could any tell me how to resolve this error or how to configure to increase
the memory to insert large data.


​You seem to either be under or mis-reporting your setup here.  The specific error is that an indexed data element cannot be larger than 8191 bytes but the value you are attempting to insert into the index is larger​
 
​than that.  As your example does not include an index there must be something else involved that does.

​Without a much more detailed, and ideally self-contained, setup it will not be possible to advise further.

Resolution of the error generally involves not constructing an index on fields that can become larger than 8191 bytes.

This value is supposedly documented but finding it appears to be non-trivial...

Its the act of insertion of a too-large document into an indexed column that provokes the complaint.  The index creation has already occurred.

If you know how to use "psql" it would be good to show descriptions of the relevant objects using its facilities.  The same can generally be accomplished via pgAdmin or whatever tool you use to inspect the database.

David J.

Yes, I am able to resolve the issue which is reported for creating an index.
I create the table with "UNIQUE" for the column like below.
-> create table sample(id serial, info jsonb unique);

So when i tried to insert the data into the table it showing cannot create
the index on the row. So I removed the unique constraint from the info
column. Hence it is resolved.



--
View this message in context:
http://postgresql.nabble.com/org-postgresql-util-PSQLException-ERROR-index-row-requires-more-memory-than-default-8191-tp5899379p5900548.html
Sent from the PostgreSQL - sql mailing list archive at Nabble.com.