tuple maximum size; plpgsql to sendmail?
tuple maximum size; plpgsql to sendmail?
От:
ERIC Lawson - x52010 <eric@bioeng.washington.edu>
Дата:
Hi, and TIA, Can anybody here answer these questions: 1) I've seen references to the maximum size of a tuple as being configurable within the range of 8 to 32K, yet the incorporation of blobs seems to contradict any maximum size constraint. Is there a maximum tuple size, and if so, what is it? (To be sure, the server environment limits the size of a tuple, attribute and class, but does postgreSQL imposes limits itself?) 2) I'd like to use a plpgsql procedure to send mail when a trigger event or condition pertains (e.g., when the interval between the system date and a date stored in an attribute reaches 14 days). Is this possible with plpgsql, and how would it be achieved? regards, Eric James Eric Lawson Research Publications Editor III National Simulation Resource eric@bioeng.washington.edu
Re: tuple maximum size; plpgsql to sendmail?
От:
Andrew McMillan <Andrew@catalyst.net.nz>
Дата:
ERIC Lawson - x52010 wrote:
>
> Hi, and TIA,
>
> Can anybody here answer these questions:
>
> 1) I've seen references to the maximum size of a tuple as being
> configurable within the range of 8 to 32K, yet the incorporation of blobs
> seems to contradict any maximum size constraint. Is there a maximum tuple
> size, and if so, what is it? (To be sure, the server environment limits
> the size of a tuple, attribute and class, but does postgreSQL imposes
> limits itself?)
A bit less than 8k is the 'default' limit (8k less tuple overhead). You
can use the 'LZTEXT' type to compress large text fields though, as a
first approach. You can recompile PostgreSQL with the block size set
larger (up to 32k) so the limit increases to a bit less than 32k.
Coming in version 7.1 is a thing called 'TOAST' (it's in current CVS)
which will let you store larger tuples - have a read about it on the
website.
> 2) I'd like to use a plpgsql procedure to send mail when a trigger event
> or condition pertains (e.g., when the interval between the system date and
> a date stored in an attribute reaches 14 days). Is this possible with
> plpgsql, and how would it be achieved?
A PL/PGSQL procedure won't run by itself. You would have to set
something up to do a pass through the database looking for such records
periodically.
SELECT * FROM tbl WHERE tbl.c_time < (now() - timespan('14 days'));
would be a suitable SQL query. If the c_time field is indexed it would
use an indexed lookup and so should be efficient.
You could run such a query in a shell script like:
IDLIST=`psql -d database -c "SELECT my_id FROM tbl WHERE tbl.c_time <
(now() - timespan('14 days'));"`
for ID in $IDLIST
do
echo "$ID expired" | mail -s "$ID expired" user@email.dom
done
If you're doing much more complex stuff than that I'd go for a
higher-level language for the scripting such as Perl, Python or C.
Hope this is some assistance,
Andrew.
--
_____________________________________________________________________
Andrew McMillan, e-mail: Andrew@cat-it.co.nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267
Re: tuple maximum size; plpgsql to sendmail?
От:
ghaverla@freenet.edmonton.ab.ca
Дата:
On Thu, 13 Jul 2000, ERIC Lawson - x52010 wrote: > Hi, and TIA, > > Can anybody here answer these questions: > > 1) I've seen references to the maximum size of a tuple as being > configurable within the range of 8 to 32K, yet the incorporation of blobs > seems to contradict any maximum size constraint. Is there a maximum tuple > size, and if so, what is it? (To be sure, the server environment limits > the size of a tuple, attribute and class, but does postgreSQL imposes > limits itself?) As pointed out, the default maximum size of a tuple is slightly less than 8k (but can be increased at compile time). Think of a blob as a pointer to storage, so the pointer takes 4 bytes (or something small like that). If you want to search inside the blob for things, you need to do that with the help of external programs (as far as I can tell so far). Gord Matter Realisations http://www.materialisations.com/ Gordon Haverland, B.Sc. M.Eng. President 101 9504 182 St. NW Edmonton, AB, CA T5T 3A7 780/481-8019 ghaverla @ freenet.edmonton.ab.ca