X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 868305E46F5 for ; Tue, 17 Aug 2004 11:12:32 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 89226-03 for ; Tue, 17 Aug 2004 14:12:32 +0000 (GMT) Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by svr1.postgresql.org (Postfix) with SMTP id 9C9295E46E6 for ; Tue, 17 Aug 2004 11:12:29 -0300 (ADT) Received: (qmail 21662 invoked from network); 17 Aug 2004 14:12:30 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.36?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 17 Aug 2004 14:12:30 -0000 Subject: Re: Advice From: Dave Cramer Reply-To: pg@fastcrypt.com To: lane@opendoors.com Cc: "pgsql-jdbc@postgresql.org" In-Reply-To: <4121697C.5010307@opendoors.com> References: <4121697C.5010307@opendoors.com> Content-Type: text/plain Organization: Cramer Consulting Message-Id: <1092752033.1622.232.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Tue, 17 Aug 2004 10:13:53 -0400 Content-Transfer-Encoding: 7bit X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/102 X-Sequence-Number: 10824 Lane, Greetings, we chatted a while back on the webmacro list... Yes, just ask on the list, or the postgres irc channel, couple of things: sequence generation is atomic (it transcends transactions, can't be rolled back, etc.), and they are not "special" in the sense that the driver doesn't know anything about generated keys. There are two functions to get a sequence, nextval('sequence_name'), and currval('sequence_name'); nextval will increment the sequence and return the next value. currval returns the result of the last executed nextval by this connection. In other words if con1 and con2 both do a nextval then calling currval on con1 will get the value generated by nextval on that connection. there is a well known issue with serial8. The index will not be used if you do select foo where serialvalue=1; you need to cast the 1 to int8 ie select foo where serialvalue=1::int8 ( this is fixed in 8.0 ) re locking: postgresql is an MVCC db, so you should very carefully read the sections on transactions, and visibility. Cheers, Dave On Mon, 2004-08-16 at 22:12, Lane Sharman wrote: > Greetings, > > I am new to PG but have been writing JAVA since 1.0 and working with SQL > for much longer than that. I am the author of VeryLargeHashtable > (http://www.webmacro.org/VeryLargeHashtable for info). In short, VLH > takes a common Java idiom, the Hashtable, and makes the backing store a > DB table instead of volatile memory. For many java applications, this is > a perfect persistence scheme. > > The component was developed under Oracle and now I want to extend it to > the Postgres dialect. I need some advice on DDL and optimizing under PG. > > Is there someone on this list that I could converse with very briefly > offline about BLOB versus bytea types, sequence generators and table/row > locking inside a jdbc-centric component. > > many thanks in advance for a small bit of your time! -- Dave Cramer 519 939 0336 ICQ # 14675561