Re: [SQL] Create Primary Key + Massive Copy's?

2000-08-29 Thread Webb Sprague
This is my next approach--I got rid of all indexes and PK's, and then created an index with unique after everything is added. Wish me luck. W --- Stephan Szabo <[EMAIL PROTECTED]> wrote: > > We don't currently support the SQL syntax for adding > a PK to a table. However, if you have the column

Re: [SQL] Optimizing huge inserts/copy's

2000-08-29 Thread Stephan Szabo
On Tue, 29 Aug 2000, Jie Liang wrote: > Hi, there, > > 1. use copy ... from '.'; > 2. write a PL/pgSQL function and pass multiple records as an array. > > However, if your table have a foreign key constraint, it cannot be speed > up, > > I have same question as you, my table invloving 9-1

Re: [SQL] Create Primary Key?

2000-08-29 Thread Jie Liang
Hi, It suppose to use ALTER TABLE tablename ADD constraint xxx primary key(columnname), unforturatly, Pg7.0 still haven't implemented it yet, so except foreign key ,other constarints, you have to choose: 1. rename your old table, recreate an new one with primary key, then use insert into newtabl

Re: [SQL] Optimizing huge inserts/copy's

2000-08-29 Thread Jie Liang
Hi, there, 1. use copy ... from '.'; 2. write a PL/pgSQL function and pass multiple records as an array. However, if your table have a foreign key constraint, it cannot be speed up, I have same question as you, my table invloving 9-13 million rows, I don't know how can I add a foreign key t

Re: [SQL] Create Primary Key?

2000-08-29 Thread Stephan Szabo
We don't currently support the SQL syntax for adding a PK to a table. However, if you have the columns as NOT NULL already, adding a unique index to the columns in question has the same general effect. Stephan Szabo [EMAIL PROTECTED] On Tue, 29 Aug 2000, Webb Sprague wrote: > Apropos of my la

[SQL] Create Primary Key?

2000-08-29 Thread Webb Sprague
Apropos of my last question: Is there syntax to create a primary key after the table has been defined and populated? I think I could speed things up quite a bit by not having any indexes at all when I do my mass copies. Thanks, and my apologies if that is a totally stupid question. W

[SQL] Optimizing huge inserts/copy's

2000-08-29 Thread Webb Sprague
Hi all, Does anybody have any thoughts on optimizing a huge insert, involving something like 3 million records all at once? Should I drop my indices before doing the copy, and then create them after? I keep a tab-delimited file as a buffer, copy it, then do it again about 400 times. Each separ

Re: [SQL] Problems with complex queries ...

2000-08-29 Thread Stephan Szabo
Without seeing the schema or anything, a similar query to your first one appears to run on my Postgres 7.0.2 setup. It's probably worth upgrading. On Wed, 30 Aug 2000, J. Fernando Moyano wrote: > I try this on my system: (Postgres 6.5.2, Linux) > > "select n_lote from pedidos except select rp

Re: [SQL] Problems with complex queries ...

2000-08-29 Thread Tom Lane
"J. Fernando Moyano" <[EMAIL PROTECTED]> writes: > I try this on my system: (Postgres 6.5.2, Linux) > "select n_lote from pedidos except select rp.n_lote from relpedidos rp, > relfacturas rf where rp.n_lote=rf.n_lote group by rp.n_lote having > sum(rp.cantidad)=sum(rf.cantidad)" > and I get thi

[SQL] Problems with complex queries ...

2000-08-29 Thread J. Fernando Moyano
Hey everybody !!! I am new on this list !!! I have a little problem . I try this on my system: (Postgres 6.5.2, Linux) "select n_lote from pedidos except select rp.n_lote from relpedidos rp, relfacturas rf where rp.n_lote=rf.n_lote group by rp.n_lote having sum(rp.cantidad)=sum(rf.cantida

Fw: [SQL] Viewing a function

2000-08-29 Thread stuart
-Original Message- From: Stuart Foster <[EMAIL PROTECTED]> To: PG-SQL <[EMAIL PROTECTED]> Date: Wednesday, 30 August 2000 2:25 Subject: [SQL] Viewing a function Helllo Stuart, Good question. I have been fiddly with a function editor using zeos controls and I have lots of little problems

[SQL] Viewing a function

2000-08-29 Thread Stuart Foster
How can a view a function after it's created ? I've created a SQL function that I need to review and possibly change. What is the best way to go about this. TIA

Re: [SQL] Re: Argument variables for select

2000-08-29 Thread Webb Sprague
I think you have to run "createlang pltcl db-foo" from the command line. As for your boss, here are three things I can think of off the top of my head: 1. All new products take some time to learn. If you can't use Postgres perfectly in a week or so, remember that you probably can't learn to b

Re: [SQL] performance on insert/update

2000-08-29 Thread Tom Lane
Jerome Raupach <[EMAIL PROTECTED]> writes: > I have a big problem of performance, please help me. You could code the update so it only evaluates the view once, rather than twice per table2 row as you now have it: UPDATE table2 SET nb=table2.nb+view1.nb, time=table2.time+view1.tim

Re: [SQL] How do you detect row version changes in PostgreSQL?

2000-08-29 Thread Tom Lane
"Craig Manley" <[EMAIL PROTECTED]> writes: > Some databases have a hidden field that contains a row version key. > Everytime an update is performed on a row the value of the version field > changes. Does PostgreSQL have a similar hidden field? See xmin (and also cmin if you need to keep track of

Re: [SQL] Re: Argument variables for select

2000-08-29 Thread hlefebvre
Keith Wong wrote: > > Hi Andreas, > > I've worked with MS SQL stored procedures before and they are quite > powerful. Its a shame postgres doesn't have the same > level of features as offered by MS SQL, MS SQL is based on source code of Sybase v5. MS bought this source code to sybase. Sybase

Re: [SQL] Re: Argument variables for select

2000-08-29 Thread Keith Wong
Hi Andreas, I've worked with MS SQL stored procedures before and they are quite powerful. Its a shame postgres doesn't have the same level of features as offered by MS SQL, but apart from this area it is still a very good database. Perhaps in the coming versions we will see more stored procedur

[SQL] performance on insert/update

2000-08-29 Thread Jerome Raupach
I have a big problem of performance, please help me. it is my work : first : COPY table1 FROM 'file'-> 43s, INSERT INTO table2 -> 34s, UPDATE table2 -> 1mn 29s ( =2m 46s : OK) second : COPY table1 FROM 'same file' -> 1m 10s, INSERT

[SQL] Re: Argument variables for select

2000-08-29 Thread Andreas Tille
On Mon, 28 Aug 2000, Yury Don wrote: > > Create Function VarSelect ( varchar, varchar ) > >returns int > >As ' > > Declare num int ; > > > > Begin > >Select Into num Count(*) From $1 Where $2 ; > >return num; > > End ; > >' language 'plpgsql' ; > > > >

[SQL] How do you detect row version changes in PostgreSQL?

2000-08-29 Thread Craig Manley
Hi all, Some databases have a hidden field that contains a row version key. Everytime an update is performed on a row the value of the version field changes. Does PostgreSQL have a similar hidden field? If not then I guess using a before update trigger that modifies a user defined field will provi