From: | Peter Mogensen <apm(at)one(dot)com> |
---|---|
To: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Plan rows - 1 or many |
Date: | 2014-03-12 08:53:52 |
Message-ID: | 532020A0.5050306@one.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 2014-03-12 09:28, Albe Laurenz wrote:
> Peter Mogensen wrote:
>> I have an application where I would really like to be able to look at en
>> SQL query and answer the question:
>>
>> "Is this query capable of returning more than 1 row?"
>
>> Can I conclude that when plan_rows is 1 then there will never be more
>> than 1 row returned by the query?
>
> I would say no.
>
> If the planner estimates one row, that means that it guesses that
> it will be one or less.
I think "guesses" is the operative word here. Because, if the planner
can actually promise that for the example queries a gave there would be
"one or less" rows, then I'm happy.
> And a query that can potentially return many rows can certainly
> also return only one row or none at all.
But that's fine... I have no problem with an answer telling me that this
query can return any number of rows.
Hmm.. I think my question is answered by posing it in another way:
Could "plan rows" tell me whether the result of a given query could be
changed by later INSERT statements?
And the answer becomes "no", because there's a difference between
queries of the type I gave as example and queries using aggregates and
GROUP BY. ... for which the planner would also return "plan_rows = 1".
However... GROUP BY queries could have their result changed by later
INSERT statements.
/Peter
From | Date | Subject | |
---|---|---|---|
Next Message | Marko Kreen | 2014-03-12 09:30:01 | Re: libpq - lack of support to set the fetch size |
Previous Message | Albe Laurenz | 2014-03-12 08:28:00 | Re: Plan rows - 1 or many |