From: | Mark Kirkwood <markir(at)paradise(dot)net(dot)nz> |
---|---|
To: | simon(at)2ndquadrant(dot)com |
Cc: | 'Randolf Richardson' <rr(at)8x(dot)ca>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: *sigh* |
Date: | 2003-12-30 07:46:12 |
Message-ID: | 3FF12D44.2070401@paradise.net.nz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Could certainly do that - a scalar function that returns reltuples from
pg_class. I was hoping to do 2 additional things:
i) provide better accuracy than the last ANALYZE
ii) make it behave like an aggregate
So I wanted to be able to use estimated_count as you would use count, i.e:
SELECT estimated_count() FROM rel
returns 1 row, whereas the scalar function :
SELECT estimated_count(rel) FROM rel
returns the result as many times as there are rows in rel - of course
you would use
SELECT estimated_count(rel)
but hopefully you see what I mean!
BTW, the scalar function is pretty simple to achieve - here is a basic
example that ignores schema qualifiers:
CREATE FUNCTION estimated_count(text) RETURNS real AS '
SELECT reltuples FROM pg_class WHERE relname = $1;
' LANGUAGE SQL;
cheers
Mark
Simon Riggs wrote:
>
>Why not implement estimated_count as a dictionary lookup, directly using
>the value recorded there by the analyze? That would be the easiest way
>to reuse existing code and give you access to many previously calculated
>values.
>
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Shridhar Daithankar | 2003-12-30 08:34:26 | Re: [GENERAL] Is my MySQL Gaining ? |
Previous Message | B. van Ouwerkerk | 2003-12-30 07:13:19 | Re: Is my MySQL Gaining ? |