pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6587: Limit on a query is mis-documented
3+ messages / 3 participants
[nested] [flat]
* BUG #6587: Limit on a query is mis-documented
@ 2012-04-13 19:40 mboldi@prospectiv.com
0 siblings, 2 replies; 3+ messages in thread
From: mboldi@prospectiv.com @ 2012-04-13 19:40 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 6587
Logged by: Mike Boldi
Email address: mboldi@prospectiv.com
PostgreSQL version: 9.0.3
Operating system: Linux/Redhat
Description:
in the manual it says
If a limit count is given, no more than that many rows will be returned (but
possibly less, if the query itself yields less rows)
BUT !! limit caps the largest internal spool. not the rows returned.
I am doing a large query so I limit the query to 5500000 but I get 88 rows
returned. I increase this to 9000000 and get 136 rows returned ..
explain Plan ...
Aggregate (cost=1689951.65..1689951.66 rows=1 width=0)
-> Hash Join (cost=644.62..1687656.17 rows=918194 width=0)
Hash Cond: (a.email_a = o.email)
-> Subquery Scan on a (cost=0.00..1654854.18 rows=9149 width=64)
Filter: ((a.memberid_a > a.memberid_b) AND (a.email_a =
a.email_b) AND (length(a.email_a) > 0))
-> Limit (cost=0.00..1325501.10 rows=16467654 width=690)
-> Nested Loop (cost=0.00..1325501.10 rows=16467654
width=690)
-> Seq Scan on lgen_fraud_members12282
(cost=0.00..1597.14 rows=5381 width=345)
Filter: ((regcomplete <> (-8)) AND (dateid
>= 5938))
-> Index Scan using lgah11_12282 on
lgen_fraud_members12282 (cost=0.00..123.62 rows=3060 width=345)
Index Cond:
((staging.lgen_fraud_members12282.dateid >=
staging.lgen_fraud_members12282.dateid) AND
(staging.lgen_fraud_members12282.memberid >
staging.lgen_fraud_members12282.memberid))
-> Hash (cost=393.72..393.72 rows=20072 width=32)
-> Seq Scan on lgen_fraud_email o (cost=0.00..393.72
rows=20072 width=32)
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6587: Limit on a query is mis-documented
@ 2012-04-14 01:34 Greg Stark <stark@mit.edu>
parent: mboldi@prospectiv.com
1 sibling, 0 replies; 3+ messages in thread
From: Greg Stark @ 2012-04-14 01:34 UTC (permalink / raw)
To: mboldi@prospectiv.com; +Cc: pgsql-bugs
On Fri, Apr 13, 2012 at 8:40 PM, <mboldi@prospectiv.com> wrote:
> I am doing a large query so I limit the query to 5500000 but I get 88 rows
> returned. I increase this to 9000000 and get 136 rows returned ..
> explain Plan ...
Please send the query with and without the LIMIT.
It might also help to send more such as the schema and possibly even
the data if that's possible. But at least send the queries so we can
see what you're doing. The plan does not look correct for what you've
described.
--
greg
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: BUG #6587: Limit on a query is mis-documented
@ 2012-04-14 01:53 John R Pierce <pierce@hogranch.com>
parent: mboldi@prospectiv.com
1 sibling, 0 replies; 3+ messages in thread
From: John R Pierce @ 2012-04-14 01:53 UTC (permalink / raw)
To: pgsql-bugs
On 04/13/12 12:40 PM, mboldi@prospectiv.com wrote:
> Aggregate (cost=1689951.65..1689951.66 rows=1 width=0)
> -> Hash Join (cost=644.62..1687656.17 rows=918194 width=0)
> Hash Cond: (a.email_a = o.email)
> -> Subquery Scan on a (cost=0.00..1654854.18 rows=9149 width=64)
> Filter: ((a.memberid_a> a.memberid_b) AND (a.email_a =
> a.email_b) AND (length(a.email_a)> 0))
> -> Limit (cost=0.00..1325501.10 rows=16467654 width=690)
> -> Nested Loop (cost=0.00..1325501.10 rows=16467654
> width=690)
> -> Seq Scan on lgen_fraud_members12282
> (cost=0.00..1597.14 rows=5381 width=345)
> Filter: ((regcomplete<> (-8)) AND (dateid
>> >= 5938))
> -> Index Scan using lgah11_12282 on
> lgen_fraud_members12282 (cost=0.00..123.62 rows=3060 width=345)
> Index Cond:
> ((staging.lgen_fraud_members12282.dateid>=
> staging.lgen_fraud_members12282.dateid) AND
> (staging.lgen_fraud_members12282.memberid>
> staging.lgen_fraud_members12282.memberid))
> -> Hash (cost=393.72..393.72 rows=20072 width=32)
> -> Seq Scan on lgen_fraud_email o (cost=0.00..393.72
> rows=20072 width=32)
without seeing the query, I can only suggest that it appears the LIMIT
is inside of a nested query or something, as it looks like it was
applied prior to additional filtering and joining.
--
john r pierce N 37, W 122
santa cruz ca mid-left coast
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2012-04-14 01:53 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-04-13 19:40 BUG #6587: Limit on a query is mis-documented mboldi@prospectiv.com
2012-04-14 01:34 ` Greg Stark <stark@mit.edu>
2012-04-14 01:53 ` John R Pierce <pierce@hogranch.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox