pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Re: your mail
3+ messages / 3 participants
[nested] [flat]

* Re: your mail
@ 1999-02-22 18:17  Roderick A. Anderson <raanders@altoplanos.net>
  0 siblings, 0 replies; 3+ messages in thread

From: Roderick A. Anderson @ 1999-02-22 18:17 UTC (permalink / raw)
  To: pgsql-sql

On Fri, 19 Feb 1999, Eric Lee Green wrote:

> I am curious about the cost of triggers.
> 
> The MySQL guys claim that they are very expensive. But if I want to put a

Pay now, pay later is more of an issue.  Using triggers means you code
once and then all accesses use the same rules.  If the rules change you
change the triggers not every application that accesses the database.  The
other issue is non-application access to the database.  Without triggers
anyone that can login to the database can make non-rule changes to the
data.  Triggers prevent this.
  This is from a modelling prespective.  The actual design of your
database my require you to go the low-road to get the performance you
need.  Though more memory, faster disk subsystems, and a faster CPU should
help without going that low-road.

Rod
--
Roderick A. Anderson
raanders@altoplanos.net               Altoplanos Information Systems, Inc.
Voice: 208.765.6149                            212 S. 11th Street, Suite 5
FAX: 208.664.5299                                  Coeur d'Alene, ID 83814




^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: your mail
@ 1999-09-02 06:44  Zalman Stern <zalman@netcom.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Zalman Stern @ 1999-09-02 06:44 UTC (permalink / raw)
  To: lists@mne.de; +Cc: pgsql-sql

I would either validate the data in the script, or batch the records into
bunches of 100 or 1000 or whatever inserts. If one of the batches fails,
then reprocess only that batch using individual inserts.

I believe using transactions of moderate size will be faster than using
really really huge ones. There are of course also transactional semantics
issues if you have concurrent access going on.

-Z-



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: your mail
@ 1999-09-16 19:11  tjk@tksoft.com <tjk@tksoft.com>
  0 siblings, 0 replies; 3+ messages in thread

From: tjk@tksoft.com @ 1999-09-16 19:11 UTC (permalink / raw)
  To: jeff@hub.org; +Cc: pgsql-sql

Jeff,
The builtin functions lo_import and lo_export are
for files only. Because of the 8k limit, it wouldn't
be possible to insert larger values.

You need to create your own routine which stores the value in a 
file and then imports/exports it.

Something like ...
(not tested, just for an idea.)

sub writetofile {
	my $data = shift;
	my $tmpfile = &newtmpfile || return "";
	open (FILE, ">$tmpfile") || return "";
	print FILE $data;
	close (FILE);	
	return $tmpfile;
}

Then replace the following lines

> my $statement = $dbh->prepare("INSERT INTO test values('something',lo_import($largestring));");
>    $statement->execute();
>    $statement->finish();
> 
> $dbh->commit;
> $dbh->disconnect;

with 
 
my $largestring = &writetofile($largestring) || die("bad data.");
my $statement = $dbh->prepare("INSERT INTO test values('something',lo_import($largestring));");
    $statement->execute();
    $statement->finish();
 
 $dbh->commit;
 $dbh->disconnect;
unlink $largestring;
 
exit (0);


Troy


> 
> Got a presumably very quick question.
> 
> I'm writing a perl script. lets say i have a variable that's > 8k
> , for arguments sake it's 64k.
> 
> How can i insert this into a database, do i need large objects ?
> and if so, do i use the lo_import ? for some reason it seems that 
> this is only for files..
> 
> below is what i have but it doesn't seem to work..
> 
> jeff=> \d test
> Table    = test
> +----------------------------------+----------------------------------+-------+
> |              Field               |              Type                | Length|
> +----------------------------------+----------------------------------+-------+
> | blurb                            | text                             |   var |
> | message                          | oid                              |     4 |
> +----------------------------------+----------------------------------+-------+
> 
> ***************** code ********************
> 
> #!/usr/bin/perl
> 
> use strict;
> use DBI;
> 
> 
> my $dbh = DBI->connect("dbname=narf host=narf port=narf",'narf','','Pg',{'AutoCommit' => 0});
> if (!$dbh) {
>         exit print "Could not connect: $DBI::errstr\n";
> }
> 
> 
> ## lets create the large value here...
> ## this string is 64K (2^16)
> 
> 
> my $largestring = 'x';
> for (my $i=0;$i < 16 ;$i++) {
>         $largestring = $largestring . $largestring;
>         }
> 
> 
> my $statement = $dbh->prepare("INSERT INTO test values('something',lo_import($largestring));");
>    $statement->execute();
>    $statement->finish();
> 
> $dbh->commit;
> $dbh->disconnect;
> 
> thanks for the help.
> 
> ======================================================
> Jeff MacDonald
> 	jeff@hub.org	webpage: http://hub.org/~jeff
> 	jeff@pgsql.com	irc: bignose on EFnet
> ======================================================
> 
> 
> ************
> 
> 




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~1999-09-16 19:11 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-22 18:17 Re: your mail Roderick A. Anderson <raanders@altoplanos.net>
1999-09-02 06:44 Re: your mail Zalman Stern <zalman@netcom.com>
1999-09-16 19:11 Re: your mail tjk@tksoft.com <tjk@tksoft.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