[GENERAL] PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea Value in stored procedure

2005-07-09 Thread Enrico Riedel
Hi! I have the following scenario: Table: Fil_no BigSerial Fil_Namevarchar Fil_DataBytea Fil_HASHvarchar Trigger: Before Insert (in Pseudo Code) ...

[GENERAL] many updates to single row in single transaction

2005-07-09 Thread Adam Pritchard
My application needs a counter that's guaranteed to not lose any values even in case of rollbacks (so sequences are out), so I have a singleton table that keeps track of where we are in the pseudo-sequence. The table is very simple: CREATE TABLE t ( next BIGINT ); INSERT INTO t ( next ) VALUES ( 0

[GENERAL] index usage in multi-column ORDER BY

2005-07-09 Thread Adam Pritchard
Why aren't two single-column indexes used in a two-column ORDER BY clause? And is there some way to work around this? For example: CREATE TABLE t ( c1 INT, c2 INT ); CREATE INDEX c1_idx ON t(c2); CREATE INDEX c2_idx ON t(c2); EXPLAIN SELECT * FROM t ORDER BY c1, c2; "Sort (cost=69.83..72.33 rows

Re: [GENERAL] many updates to single row in single transaction

2005-07-09 Thread Dennis Bjorklund
On 8 Jul 2005, Adam Pritchard wrote: > so I have a singleton table that keeps track of where we are in the > pseudo-sequence. The table is very simple: > > CREATE TABLE t ( next BIGINT ); > INSERT INTO t ( next ) VALUES ( 0 ); > > UPDATE t SET next = $1; -- $1 = next+1 > > The problem is that

[GENERAL] Transaction isolation levels

2005-07-09 Thread Geert Jansen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I'm having some trouble with transaction isolation levels, and would appreciate some input on this. According to the documentation of PostgreSQL 8.0.3, section 12.2: "Read Committed is the default isolation level in PostgreSQL. When a transactio

Re: [GENERAL] PL/pgGRESQL, SHA, BYTEA - Creating SHA1 hash for Bytea Value in stored procedure

2005-07-09 Thread Michael Fuhr
On Fri, Jul 08, 2005 at 04:43:41PM -0500, Enrico Riedel wrote: > > I tried to find a function that calculates the SHA (preference is sha-256), > but could not find anything for PostGRE. However, I want to implement the > calculation within the DB, for several reasons. See the contrib/pgcrypto mod

Re: [GENERAL] Transaction isolation levels

2005-07-09 Thread Michael Fuhr
On Sat, Jul 09, 2005 at 01:18:09PM +0200, Geert Jansen wrote: > > The top of section 12.2 of the manual tells that nonrepeatable reads may > happen in the 'read committed' isolation level. I can understand the > above behaviour in terms of this. However, the start of section 12.2.1 > tells that in

Re: [GENERAL] index usage in multi-column ORDER BY

2005-07-09 Thread Michael Fuhr
On Fri, Jul 08, 2005 at 10:06:23AM -0700, Adam Pritchard wrote: > Why aren't two single-column indexes used in a two-column ORDER BY > clause? And is there some way to work around this? > > For example: > CREATE TABLE t ( c1 INT, c2 INT ); > CREATE INDEX c1_idx ON t(c2);

Re: [GENERAL] Transaction isolation levels

2005-07-09 Thread Geert Jansen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Michael Fuhr wrote: >What words in section 12.2.1 are you referring to? I see the >following (emphasis mine): > > In effect, a SELECT query sees a snapshot of the database as of > the instant that that *query* begins to run. Notice that two > suc

Re: [GENERAL] index usage in multi-column ORDER BY

2005-07-09 Thread Tom Lane
"Adam Pritchard" <[EMAIL PROTECTED]> writes: > CREATE TABLE t ( c1 INT, c2 INT ); > CREATE INDEX c1_idx ON t(c2); > CREATE INDEX c2_idx ON t(c2); > EXPLAIN SELECT * FROM t ORDER BY c1, c2; > "Sort (cost=69.83..72.33 rows=1000 width=8)" > " Sort Key: c1, c2" > " -> Seq Scan on t (cost=0.00..20.

Re: [GENERAL] Transaction isolation levels

2005-07-09 Thread Tom Lane
Geert Jansen <[EMAIL PROTECTED]> writes: > For my curiosity, what is the reason that in read comitted mode MVCC can > guarantee a consistent snapshot durign a query, while in serializable > mode MVCC can guarantee it for a longer interval (the entire > transaction). Are these different MVCC impl

[GENERAL] checkpoint segments

2005-07-09 Thread Havasvölgyi Ottó
Hi, I have a small database on my Windows XP, I rarely use it. Even so, the log file show says this: [2005-07-02 02:02:09] LOG: received fast shutdown request [2005-07-02 02:02:09] LOG: checkpoints are occurring too frequently (0 seconds apart) [2005-07-02 02:02:09] HINT: Consider increasi

Re: [GENERAL] checkpoint segments

2005-07-09 Thread Havasvölgyi Ottó
Hi, Sorry, this is Pg 8.0.3 Regards, Otto ---(end of broadcast)--- TIP 9: In versions below 8.0, the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match

Re: [GENERAL] checkpoint segments

2005-07-09 Thread Bruce Momjian
There was a problem with this setting that it reports during shutdown when in fact it should ignore shutdown checkpoints. This is fixed in 8.1. --- Havasv?lgyi Ott? wrote: > Hi, > > I have a small database on my Windows XP

[GENERAL] Update more than one table

2005-07-09 Thread David Pratt
Hi. I have a form that collects information from the user but then I need to update three separate tables from what the user has submitted. I could do this with application logic but I would feel it would be best handled in Postgres as a transaction. I need to do things in this order to satisf