I'm running in my jboss 5.1-java-jpa-hibernate-postgresql application a select query. This query is a UNION query of arroung 10 queries and normally for now it should return around 25.000 BigInteger numbers (more to become later). Yesterday this function worked fine. Today I got the following error. Can someone please advice? I can't find much about this error.

ERROR: stack depth limit exceeded Hint: Increase the configuration parameter "max_stack_depth", after ensuring the platform's stack depth limit is adequate.

If I run the 10 queries one after another alone and then add the results in one ArrayList will that help?


EDIT:

Postgresql version used: postgresql-9.0-801.jdbc4.jar

I can't show the exact query for security reasons. But it is something like:

SELECT * FROM (
    SELECT fileId FROM table1
    UNION
    SELECT fileId FROM table2
    ...
    ...
    SELECT fileId FROM table_n
);

This query returns now arround 25.000 BigInteger entries ( which are about to reach 120.000 in the future ). Any suggestions?

share|improve this question
    
Please show the PostgreSQL version, the query text, and the EXPLAIN of the query. Are there PL/PgSQL functions involved? – Craig Ringer Mar 22 '13 at 9:47
    
@CraigRinger please check the edit in original post. – Panos Mar 22 '13 at 10:17
    
You should figure out a statment, that causes that problem, but you can post. In most cases this is enough to understand and often even to solve the problem. If not you have at least something to post – Sir RotN Mar 22 '13 at 11:49
up vote 0 down vote accepted

Problem solved. This occurred by a very very big query sent to postgresql.

There was a bug in the code that created dynamically the query, and instead of 10 queries in one union query, it replicated them and had hundreds of the same query series in one union query. All this caused a huge query in the db and consequently a transaction timeout in the database.

I changed the code to execute each query by its self and merge the results using code. Of course I fixed the bug and it generates only the 10 right queries.

Thanks all for the help.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.