Thread: max length of sql select statement ?

max length of sql select statement ?

From
markus brosch
Date:
Hi All!

I was searching the archive and was wondering why nobody asked this
strange question (or I've not found it?):

"What is the max allowed length of a sql statement or query?"
I want to combine hundrets or thousands 'OR' within a select statement.
Possible or not?

cheers Markus



Re: max length of sql select statement ?

From
"scott.marlowe"
Date:
On 7 Jul 2003, markus brosch wrote:

> Hi All!
> 
> I was searching the archive and was wondering why nobody asked this
> strange question (or I've not found it?):
> 
> "What is the max allowed length of a sql statement or query?"
> I want to combine hundrets or thousands 'OR' within a select statement.
> Possible or not?

the maximum length is not limited.  i.e.

insert into table badabing values ('10 gig text field goes here');

is legal and will work assuming your machine can handle such a large field 
size.  i.e. a pentium 100 with 64 meg ram, 64 meg swap and a 500 meg hard 
drive can't handle it because of hardware limits, but a Sun E10k with 64 
Gigs ram, 64 CPUs, and a 2200 gig raid array likely would.

How many OR statements can be handled is probably limited by some internal 
counter or something.  More than likely long before the database has 
"issues" with too many OR statements, you'll have issues with the 
performance (i.e. a non-linear performance curve is likely to exist as you 
start swapping out or something like that.)

I'd say experiment and see where postgresql starts to have issues.  I'd 
certainly like to know too.

I know that dozens or even hundreds of or terms are possible, thousands, 
not so sure.