Re: [HACKERS] RE: [GENERAL] urgent: problems with query_limit

From: wieck(at)debis(dot)com (Jan Wieck)
To: mascarim(at)yahoo(dot)com (Marcus Mascari)
Cc: pgsql-general(at)postgreSQL(dot)org, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] RE: [GENERAL] urgent: problems with query_limit
Date: 1999-07-01 00:47:56
Message-ID: m10zV1A-0003ktC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Marcus "Mike" Mascari wrote:

> What I would like to see (perhaps its possible
> right now, or a workaround is available) is a method
> for yielding an elog() message when the number of
> tuples to be returned is over a specified USER limit.
>
> [...]
>
> However, what we would like to prevent is some
> new user, unfamiliar with how to design aggregate
> and restrive queries, from doing a SELECT * FROM sales
> and having 1 gig of data shipped across the network
> to their Excel, Access, or Crystal Report Writer
> application. Instead, we would like to generate
> an elog() error in the backend like:
>
> "You are allowed to return a maximum of 20,000 rows."

I don't think that this is easy to implement because it is in
conflict with the general design of the PostgreSQL
optimizer/executor combo.

If possible (no sorting or grouping), the execution plan is
setup in a way that the data is directly fed from the table
to the client. So when the maximum exceeds, the client
already received that many rows.

And how should the database know how many rows it WILL send
before collecting them all? Well, in the case of a simple
"SELECT * FROM sales" it could look at the statistics. But on
a simple join between "salesorg" and "sales" it is only
possible to guess how many rows this MIGHT produce (the
optimizer uses this guessing to decide the joining and where
indices might be helpful). But the exact number of rows is
only known after the complete execution of the plan - and
then they are already sent to the client.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#========================================= wieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 1999-07-01 04:53:22 Re: [GENERAL] urgent: problems with query_limit
Previous Message Chris Bitmead 1999-07-01 00:44:14 Re: [GENERAL] Fast join

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 1999-07-01 01:33:49 RE: [HACKERS] 6.5.1 status
Previous Message Tom Lane 1999-07-01 00:45:39 Re: [HACKERS] regression bigtest needs very long time