Re: max length of sql select statement ?

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: markus brosch <brosch(at)gmx(dot)de>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: max length of sql select statement ?
Date: 2003-07-07 16:23:39
Message-ID: 20030707091855.O77173-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On 7 Jul 2003, markus brosch wrote:

> 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?"

AFAIR in recent versions it's effectively limited only by resources (how
much bandwidth/memory do you want to use).

> I want to combine hundrets or thousands 'OR' within a select statement.
> Possible or not (e.g: SELECT * FROM table WHERE col='a' OR col='b' OR
> col='c' OR ...... )

It should be possible.

> This would be a very "dirty" or some would say, a "horrible" solution;
>
> but how are you searching through your table with sql, when your SELECT
> is against a collection of different elements (e.g. Array of Strings,
> which should fit on one column and return all records which fit)

Are the 'a', 'b', etc... fixed or generated on the fly? I'm not sure
that the plan for a thousand OR clauses (or equivalently a thousand
entries in a static IN) is going to necessarily be terribly good. You
might have better luck setting it up to do a join with a table (possibly a
temporary table if they're generated on the fly).

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message markus brosch 2003-07-07 16:23:55 Re: max length of sql select statement ?
Previous Message Rod Taylor 2003-07-07 16:20:53 Re: max length of sql select statement ?