Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Tim Uckun
Oh I forgot SELECT version(); PostgreSQL 9.2.2 on x86_64-apple-darwin12.2.1, compiled by Apple clang version 4.1 (tags/Apple/clang-421.11.65) (based on LLVM 3.1svn), 64-bit SELECT name, current_setting(name), source FROM pg_settings WHERE source NOT IN ('default', 'override');

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Steve Crawford
On 01/21/2013 03:45 PM, Tim Uckun wrote: Oh I forgot ... shared_buffers;1600kB;configuration file You *reduced* shared buffers to 1.6MB? IIRC the typical default is 32MB and the most common adjustment is to *increase* shared buffers. Most of my servers are set to 2GB. Try bumping that up

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Steve Crawford
On 01/21/2013 04:15 PM, Steve Crawford wrote: On 01/21/2013 03:45 PM, Tim Uckun wrote: Oh I forgot ... Me, too. I forgot to ask for the table definition. If there are variable-length fields like text or varchar, what is the typical size of the data. Also, what is the physical size of the

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Tim Uckun
I already posted the schema earlier. It's a handful of integer fields with one hstore field. On Tue, Jan 22, 2013 at 1:23 PM, Steve Crawford scrawf...@pinpointresearch.com wrote: select * from pg_stat_user_tables where relname='yourtable'; Messy output

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Kevin Grittner
Kevin Grittner wrote: update imports set make_id = 0 Query returned successfully: 98834 rows affected, 45860 ms execution time. For difficult problems, there is nothing like a self-contained test case, that someone else can run to see the issue. Here's a starting point: create extension if

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Jeff Janes
On Monday, January 21, 2013, Tim Uckun wrote: First off, what does it say for rows affected? (Hint, if you really are using a default configuration and it doesn't say 0 rows affected, please show us the actual query used.) update imports set make_id = null Query returned successfully:

Re: [GENERAL] Running update in chunks?

2013-01-21 Thread Jeff Janes
On Monday, January 21, 2013, Tim Uckun wrote: I already posted the schema earlier. It's a handful of integer fields with one hstore field. one hstore field can easily be equivalent to 50 text fields with an index on each one. I'm pretty sure that that is your bottleneck. what does \di+

[GENERAL] Frequent update - how to do?

2012-12-21 Thread grell
Hi, Firstly I will tell you what I'm trying to do: I have a database. I have a table Person. Person has location and this location need to be updated f.e. every 5 min or with higher frequently. Should I have some special tool, table or whatever to keep this data? I want to have history of

Re: [GENERAL] Frequent update - how to do?

2012-12-21 Thread John R Pierce
On 12/19/2012 5:44 AM, grell wrote: Firstly I will tell you what I'm trying to do: I have a database. I have a table Person. Person has location and this location need to be updated f.e. every 5 min or with higher frequently. Should I have some special tool, table or whatever to keep this data?

Re: [GENERAL] index update

2012-07-18 Thread Thomas Munro
Pawel Veselov pawel.vese...@gmail.com wrote: Hi. If I have a lot (10k) tables, and each table has a btree index, and all the tables are being constantly inserted into, would all the indexes have to be in memory, and would effectively start fighting for space? Thank you, Pawel. -- Sent via

[GENERAL] index update

2012-07-17 Thread Pawel Veselov
Hi. If I have a lot (10k) tables, and each table has a btree index, and all the tables are being constantly inserted into, would all the indexes have to be in memory, and would effectively start fighting for space? Thank you, Pawel.

Re: [GENERAL] index update

2012-07-17 Thread Craig Ringer
On 07/18/2012 12:02 PM, Pawel Veselov wrote: Hi. If I have a lot (10k) tables, and each table has a btree index, and all the tables are being constantly inserted into, would all the indexes have to be in memory, and would effectively start fighting for space? Quite likely, yes. You could

Re: [GENERAL] index update

2012-07-17 Thread Pawel Veselov
On Tue, Jul 17, 2012 at 9:18 PM, Craig Ringer ring...@ringerc.id.au wrote: On 07/18/2012 12:02 PM, Pawel Veselov wrote: Hi. If I have a lot (10k) tables, and each table has a btree index, and all the tables are being constantly inserted into, would all the indexes have to be in memory,

[GENERAL] ARD update warning (Mac stuff)

2012-06-30 Thread Scott Ribe
If you install the latest ARD update (which does not require a reboot), it apparently does something similar to: sudo killall postmaster Oops. Thanks, Apple. -- Scott Ribe scott_r...@elevated-dev.com http://www.elevated-dev.com/ (303) 722-0567 voice -- Sent via pgsql-general mailing

[GENERAL] undo update

2012-03-15 Thread Ivan
Hi all. Today an accident happened on one of my databases. I have a table named payments with about 5400 rows. I have done a query update payments set amount = 0; where id in (2354,2353,1232). Please note the semicolon inside — I missed it =( Now all my data is lost. And after this happened I

Re: [GENERAL] undo update

2012-03-15 Thread Scott Marlowe
On Thu, Mar 15, 2012 at 8:22 AM, Ivan kuzma...@gmail.com wrote: Hi all. Today an accident happened on one of my databases. I have a table named payments with about 5400 rows. I have done a query update payments set amount = 0; where id in (2354,2353,1232). Please note the semicolon inside —

Re: [GENERAL] undo update

2012-03-15 Thread Ivan
I have installed xlogviewer and it gives me data like that: [cur:0/5770E87C, xid:355075, rmid:10(Heap), len:88/116, prev:0/5770E840] update: s/d/r:1663/90693/107093 block 1 off 36 to block 107 off 30 [cur:0/5770E8F0, xid:355075, rmid:11(Btree), len:34/62, prev:0/5770E87C] insert_leaf:

Re: [GENERAL] undo update

2012-03-15 Thread Steve Crawford
On 03/15/2012 07:22 AM, Ivan wrote: Hi all. Today an accident happened on one of my databases. I have a table named payments with about 5400 rows. I have done a query update payments set amount = 0; where id in (2354,2353,1232). Please note the semicolon inside — I missed it =( Now all my

[GENERAL] Calculated update

2012-03-12 Thread Bret Stern
trying to update a varchar numeric string column by converting it to int, adding a numeric value and insert it back as a varchar Having trouble with cast -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] Calculated update

2012-03-12 Thread Rob Sargent
On 03/12/2012 06:28 PM, Bret Stern wrote: trying to update a varchar numeric string column by converting it to int, adding a numeric value and insert it back as a varchar Having trouble with cast Possibly having trouble with two casts: one from string to int, one from int to string? You

Re: [GENERAL] Calculated update

2012-03-12 Thread Bosco Rama
Bret Stern wrote: trying to update a varchar numeric string column by converting it to int, adding a numeric value and insert it back as a varchar Having trouble with cast I assume you are doing an update as opposed to an insert. You use both above (and both numeric and int as well).

Re: [GENERAL] Calculated update

2012-03-12 Thread Bret Stern
On Mon, 2012-03-12 at 17:39 -0700, Bosco Rama wrote: Bret Stern wrote: trying to update a varchar numeric string column by converting it to int, adding a numeric value and insert it back as a varchar Having trouble with cast I assume you are doing an update as opposed to an

[GENERAL] Dynamic update of a date field

2012-02-16 Thread Musial, Jan (GIUB)
Dear all, I have a question concerning default value/trigger function which supposed to update/fill field called time_stamp whenever a row is inserted. Let say that we have a table: CREATE TABLE dummy (year smallint,month smallint,day smallint,time_stamp date); I would like to update time_stamp

Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread Andreas Kretschmer
Musial, Jan (GIUB) jan.mus...@giub.unibe.ch wrote: Dear all, I have a question concerning default value/trigger function which supposed to update/fill field called time_stamp whenever a row is inserted. Let say that we have a table: CREATE TABLE dummy (year you can use 'default now()' or

Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread Adrian Klaver
On Thursday, February 16, 2012 6:05:40 am Musial, Jan (GIUB) wrote: Dear all, I have a question concerning default value/trigger function which supposed to update/fill field called time_stamp whenever a row is inserted. Let say that we have a table: CREATE TABLE dummy (year smallint,month

Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread Musial, Jan (GIUB)
separately than create a timestamp and drop the columns. All the best, Jan Von: Adrian Klaver [adrian.kla...@gmail.com] Gesendet: Donnerstag, 16. Februar 2012 15:56 An: pgsql-general@postgresql.org Cc: Musial, Jan (GIUB) Betreff: Re: [GENERAL] Dynamic

Fwd: Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread David Salisbury
On 2/16/12 7:27 AM, Andreas Kretschmer wrote: Musial, Jan (GIUB)jan.mus...@giub.unibe.ch wrote: smallint,month smallint,day smallint,time_stamp date); I would like to That's silly, use one (and only one) field, timestamp (or timestamptz) Don't use never ever multiple columns for the same

Re: Fwd: Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread John R Pierce
On 02/16/12 2:34 PM, David Salisbury wrote: Would it not be advantageous to replicate information in the above form if you wanted to, say, get all records in the month of May, and therefore create an index on the month field? I would think that would be more efficient than creating a

Re: Fwd: Re: [GENERAL] Dynamic update of a date field

2012-02-16 Thread Steve Crawford
On 02/16/2012 02:45 PM, John R Pierce wrote: On 02/16/12 2:34 PM, David Salisbury wrote: Would it not be advantageous to replicate information in the above form if you wanted to, say, get all records in the month of May, and therefore create an index on the month field? I would think that

Re: [GENERAL] simple update query too long

2011-05-13 Thread F T
Thanks for your ideas. I have rerun my tests and I agree with Merlin, PostgreSQL is not adapted at all to handle wide updates. Summary : The table contains 2 millions rows. Test 1 : UPDATE grille SET inter=0; - It tooks 10 hours Test 2 : I remove the spatial Gist index, and the constraints : I

Re: [GENERAL] simple update query too long

2011-05-13 Thread Pavel Stehule
2011/5/13 F T ouk...@gmail.com: Thanks for your ideas. I have rerun my tests and I agree with Merlin, PostgreSQL is not adapted at all to handle wide updates. Summary : The table contains 2 millions rows. Test 1 : UPDATE grille SET inter=0; - It tooks 10 hours Test 2 : I remove the

Re: [GENERAL] simple update query too long

2011-05-13 Thread Oleg Bartunov
On Fri, 13 May 2011, F T wrote: Thanks for your ideas. I have rerun my tests and I agree with Merlin, PostgreSQL is not adapted at all to handle wide updates. Summary : The table contains 2 millions rows. Test 1 : UPDATE grille SET inter=0; - It tooks 10 hours Test 2 : I remove the spatial

Re: [GENERAL] simple update query too long

2011-05-13 Thread Misa Simic
Hi, Would it be faster if you create Partial Index on inter field (btree) where inter 0 and then UPDATE grille SET inter = 0 WHERE inter 0 Kind Regards, Misa 2011/5/9 F T ouk...@gmail.com Hi list I use PostgreSQL 8.4.4. (with Postgis 1.4) I have a simple update query that takes hours

Re: [GENERAL] simple update query too long

2011-05-13 Thread Isabella Ghiurea
Hi, I would suggest if you can try one of this options: 0- create a new index on inter column for grille table and in your WHERE clause try to limit the number of update rows instead of 2mills for one the whole transaction , something like :where inter x and inter y; 1- drop at least the

Re: [GENERAL] simple update query too long

2011-05-13 Thread Merlin Moncure
On Fri, May 13, 2011 at 2:07 AM, F T ouk...@gmail.com wrote: Thanks for your ideas. I have rerun my tests and I agree with Merlin, PostgreSQL is not adapted at all to handle wide updates. Summary : The table contains 2 millions rows. Test 1 : UPDATE grille SET inter=0; - It tooks 10

[GENERAL] simple update query too long

2011-05-09 Thread F T
Hi list I use PostgreSQL 8.4.4. (with Postgis 1.4) I have a simple update query that takes hours to run. The table is rather big (2 millions records) but it takes more than 5 hours to run !! The query is just : *UPDATE grille SET inter = 0* The explain command seems ok : Seq Scan on grille50

Re: [GENERAL] simple update query too long

2011-05-09 Thread Guillaume Lelarge
On 05/09/2011 04:39 PM, F T wrote: Hi list I use PostgreSQL 8.4.4. (with Postgis 1.4) I have a simple update query that takes hours to run. The table is rather big (2 millions records) but it takes more than 5 hours to run !! The query is just : *UPDATE grille SET inter = 0* The

Re: [GENERAL] simple update query too long

2011-05-09 Thread tv
On 05/09/2011 04:39 PM, F T wrote: Hi list I use PostgreSQL 8.4.4. (with Postgis 1.4) I have a simple update query that takes hours to run. The table is rather big (2 millions records) but it takes more than 5 hours to run !! The query is just : *UPDATE grille SET inter = 0* So any

Re: [GENERAL] simple update query too long

2011-05-09 Thread Merlin Moncure
On Mon, May 9, 2011 at 10:29 AM, t...@fuzzy.cz wrote: On 05/09/2011 04:39 PM, F T wrote: Hi list I use PostgreSQL 8.4.4. (with Postgis 1.4) I have a simple update query that takes hours to run. The table is rather big (2 millions records) but it takes more than 5 hours to run !! The

[GENERAL] BEFORE UPDATE trigger also fires at insert?

2011-05-08 Thread Clemens Eisserer
Hi, I've defined a small trigger to increment a field each time the row is updated: CREATE TRIGGER inc_trigger BEFORE UPDATE ON Table FOR EACH ROW EXECUTE PROCEDURE inc_function(); Works quite well, however the trigger is also fired if the table itself is modified. When deleting or inserting

Re: [GENERAL] BEFORE UPDATE trigger also fires at insert?

2011-05-08 Thread Tom Lane
Clemens Eisserer linuxhi...@gmail.com writes: I've defined a small trigger to increment a field each time the row is updated: CREATE TRIGGER inc_trigger BEFORE UPDATE ON Table FOR EACH ROW EXECUTE PROCEDURE inc_function(); Works quite well, however the trigger is also fired if the table

[GENERAL] Are Update rights on the target table of a do instead update rule necessary ?

2011-04-16 Thread Geraldo Lopes de Souza
Hi, I'm trying to implement tenant view filter with postgres. The docs says Rewrite rules don't have a separate owner. The owner of a relation (table or view) is automatically the owner of the rewrite rules that are defined for it. The PostgreSQL rule system changes the behavior of the default

[GENERAL] Revisiting UPDATE FROM ... ORDER BY not respected

2011-04-12 Thread Carlo Stonebanks
A few years ago I asked about creating a single UPDATE statement to assign id's from a sequence, with the sequences applied in a particular order. In other words, order the table, then apply nextval-generated id's to the id field in question. Here is the original post:

Re: [GENERAL] Revisiting UPDATE FROM ... ORDER BY not respected

2011-04-12 Thread Tom Lane
Carlo Stonebanks stonec.regis...@sympatico.ca writes: A few years ago I asked about creating a single UPDATE statement to assign id's from a sequence, with the sequences applied in a particular order. In other words, order the table, then apply nextval-generated id's to the id field in

Re: [GENERAL] Revisiting UPDATE FROM ... ORDER BY not respected

2011-04-12 Thread Carlo Stonebanks
: [GENERAL] Revisiting UPDATE FROM ... ORDER BY not respected Carlo Stonebanks stonec.regis...@sympatico.ca writes: A few years ago I asked about creating a single UPDATE statement to assign id's from a sequence, with the sequences applied in a particular order. In other words, order the table

Re: [GENERAL] why update is slower on my pc?

2010-12-27 Thread Jasen Betts
On 2010-12-26, sunpeng blueva...@gmail.com wrote: First I wondered whether the write speed on pc is lower than laptop, so i use a cp command to test a write speed: that is often a test of read speed only. as the writes will be cached. -- ⚂⚃ 100% natural -- Sent via pgsql-general mailing

[GENERAL] why update is slower on my pc?

2010-12-26 Thread sunpeng
I use my laptop to execute the following sql, it's: mydb=# update _mcir_2597431_clusterid2 set clusterid = 3; UPDATE 104770 Time: 8666.447 ms and on my pc: mydb=# update _mcir_2597431_clusterid2 set clusterid = 3; UPDATE 104770 Time: 27171.203 ms First I wondered whether the write speed on pc is

Re: [GENERAL] why update is slower on my pc?

2010-12-26 Thread Satoshi Nagayasu
On 2010/12/26, at 21:35, sunpeng blueva...@gmail.com wrote: so the writing speed on disk of pc is much faster than laptop, why the update sql command is much slower than my laptop? what's the reason causing such decrease? Are those PostgreSQL versions and/or configurations completely same?

Re: [GENERAL] why update is slower on my pc?

2010-12-26 Thread Scott Marlowe
On Sun, Dec 26, 2010 at 5:35 AM, sunpeng blueva...@gmail.com wrote: I use my laptop to execute the following sql, it's: mydb=# update _mcir_2597431_clusterid2 set clusterid = 3; UPDATE 104770 Time: 8666.447 ms and on my pc: mydb=# update _mcir_2597431_clusterid2 set clusterid = 3; UPDATE

Re: [GENERAL] Dynamically update NEW columns in plpgsql trigger

2010-09-09 Thread Pavel Stehule
Hello plpgsql isn't good tool for this. use a plperl or plpython instead. your solution is extremly slow. Regards Pavel Stehule 2010/9/9 Nick nboutel...@gmail.com: I need to dynamically update NEW columns. Ive been inserting the NEW values into a temp table, updating them, then passing the

Re: [GENERAL] Dynamically update NEW columns in plpgsql trigger

2010-09-09 Thread Dmitriy Igrishin
Hey Nick, You may do it with PL/pgSQL more easily with hstore module. Please, refer to http://www.postgresql.org/docs/9.0/static/hstore.html Please, look at the hstore(record) and populate_record(record, hstore) function. Hope this helps. And I think it will be more faster then you solution.

Re: [GENERAL] Dynamically update NEW columns in plpgsql trigger

2010-09-09 Thread Nick
On Sep 9, 2:21 am, dmit...@gmail.com (Dmitriy Igrishin) wrote: Hey Nick, You may do it with PL/pgSQL more easily with hstore module. Please, refer tohttp://www.postgresql.org/docs/9.0/static/hstore.html Please, look at the hstore(record) and populate_record(record, hstore) function. Hope

Re: [GENERAL] Dynamically update NEW columns in plpgsql trigger

2010-09-09 Thread Merlin Moncure
On Thu, Sep 9, 2010 at 6:34 PM, Nick nboutel...@gmail.com wrote: On Sep 9, 2:21 am, dmit...@gmail.com (Dmitriy Igrishin) wrote: Hey Nick, You may do it with PL/pgSQL more easily with hstore module. Please, refer tohttp://www.postgresql.org/docs/9.0/static/hstore.html Please, look at the

[GENERAL] Dynamically update NEW columns in plpgsql trigger

2010-09-08 Thread Nick
I need to dynamically update NEW columns. Ive been inserting the NEW values into a temp table, updating them, then passing the temp table values back to NEW (is there a better way?). Ive had success with this method unless there is a null value... EXECUTE 'CREATE TEMP TABLE new AS SELECT $1.*'

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-09-01 Thread Igor Neyman
-Original Message- From: Raymond C. Rodgers [mailto:sinful...@gmail.com] Sent: Tuesday, August 31, 2010 7:56 PM To: pgsql-general@postgresql.org Subject: Table update problem works on MySQL but not Postgres Let me stress that this is not a bug in PostgreSQL; if anything at

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-09-01 Thread Ivan Voras
On 09/01/10 16:13, Igor Neyman wrote: -Original Message- From: Raymond C. Rodgers [mailto:sinful...@gmail.com] Sent: Tuesday, August 31, 2010 7:56 PM To: pgsql-general@postgresql.org Subject: Table update problem works on MySQL but not Postgres update mydemo set cat_order =

[GENERAL] Table update problem works on MySQL but not Postgres

2010-08-31 Thread Raymond C. Rodgers
Let me stress that this is not a bug in PostgreSQL; if anything at all, it's only a lack of a stupid feature. I'm working on a project for a client where I have a table for arbitrary categories to be applied to their data, and they need to be able to set the order in which the categories

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-08-31 Thread David Fetter
On Tue, Aug 31, 2010 at 07:56:23PM -0400, Raymond C. Rodgers wrote: Let me stress that this is not a bug in PostgreSQL; if anything at all, it's only a lack of a stupid feature. PostgreSQL's version involves UPDATE ... FROM. Use an ORDER BY in the FROM clause like this: UPDATE mydemo SET

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-08-31 Thread Merlin Moncure
On Tue, Aug 31, 2010 at 7:56 PM, Raymond C. Rodgers sinful...@gmail.com wrote:  Let me stress that this is not a bug in PostgreSQL; if anything at all, it's only a lack of a stupid feature. I'm working on a project for a client where I have a table for arbitrary categories to be applied to

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-08-31 Thread Joshua D. Drake
On Tue, 2010-08-31 at 20:17 -0400, Merlin Moncure wrote: This is where the interesting thing happens: On MySQL the query actually works as intended, but it doesn't on PostgreSQL. As I said, I'm sure this is not a bug in PostgreSQL, but the lack of a stupid user trick. While my project is

Re: [GENERAL] Table update problem works on MySQL but not Postgres

2010-08-31 Thread Raymond C. Rodgers
On 8/31/2010 8:17 PM, Merlin Moncure wrote: On Tue, Aug 31, 2010 at 7:56 PM, Raymond C. Rodgerssinful...@gmail.com wrote: Let me stress that this is not a bug in PostgreSQL; if anything at all, it's only a lack of a stupid feature. I'm working on a project for a client where I have a table

[GENERAL] Does update = delete + insert ?

2010-05-26 Thread Gauthier, Dave
Hi: Under the hood, does PG implement an update statement as a delete followed by an insert?I'm at a point in coding a script where it would be more expeditious for me to delete/insert a record as opposed to update and want to know if I lose anything by doing that. Thanks in Advance !

Re: [GENERAL] Does update = delete + insert ?

2010-05-26 Thread Andreas Kretschmer
Gauthier, Dave dave.gauth...@intel.com wrote: Hi: Under the hood, does PG implement an update statement as a delete followed by an insert?I’m at a point in coding a script where it would be more Yes, Update means delete the old record and create a new one. Andreas -- Really, I'm

Re: [GENERAL] Does update = delete + insert ?

2010-05-26 Thread Steve Atkins
On May 26, 2010, at 11:41 AM, Gauthier, Dave wrote: Hi: Under the hood, does PG implement an update statement as a delete followed by an insert?I’m at a point in coding a script where it would be more expeditious for me to delete/insert a record as opposed to update and want to

Re: [GENERAL] Does update = delete + insert ?

2010-05-26 Thread Gauthier, Dave
, 2010 3:05 PM To: pgsql-general General Subject: Re: [GENERAL] Does update = delete + insert ? On May 26, 2010, at 11:41 AM, Gauthier, Dave wrote: Hi: Under the hood, does PG implement an update statement as a delete followed by an insert?I'm at a point in coding a script where it would

[GENERAL] Before update trigger causing another after trigger to fire, returning NULL, causing before trigger to not update - does this make sense?

2010-04-06 Thread Susan Cassidy
Hi, I was trying to update certain columns in a table, but the update never took place, but did not throw an exception. I investigated the code in the 'before update' trigger, and put in some RAISE NOTICE statements. I could then see that another update of the same table was happening, too,

Re: [GENERAL] Before update trigger causing another after trigger to fire, returning NULL, causing before trigger to not update - does this make sense?

2010-04-06 Thread Tom Lane
Susan Cassidy scass...@stbernard.com writes: Sequence of events when problem occurred: update table a causes update table b which updates table a again (different column) trigger for table b returns null update of table a does not happen Different column of same row, you mean? Yes,

Re: [GENERAL] [HACKERS] Update on Insert

2009-11-16 Thread Thom Brown
2009/11/16 Robert Haas robertmh...@gmail.com: On Mon, Nov 16, 2009 at 1:31 PM, SebiF sfe...@gmail.com wrote: Hi Everyone, Given a table Items with a PK item1 and Qty - a numeric column I'd like to define a way in Postgres to insert when item11 doesn't exist already in Items and update the

[GENERAL] [Newbie] UPDATE based on other table content

2009-10-29 Thread Daniel Chiaramello
Hello. I have a very basic question, relative to the following problem. I have the following tables: product id qty intermediate id product_id orders intermediate_id I want to update the qty field of the product table by incrementing it each time there is an order in the

Re: [GENERAL] [Newbie] UPDATE based on other table content

2009-10-29 Thread Daniel Chiaramello
Never mind, I found how finally: UPDATE product SET qty = qty+s_count FROM ( SELECT intermediate.product_id, count(*) AS s_count FROM intermediate, orders WHERE orders.intermediate_id=intermediate.id GROUP

Re: [GENERAL] [Newbie] UPDATE based on other table content

2009-10-29 Thread Thom Brown
2009/10/29 Daniel Chiaramello daniel.chiarame...@golog.net: Never mind, I found how finally: UPDATE   product SET   qty = qty+s_count FROM (       SELECT           intermediate.product_id,           count(*) AS s_count       FROM           intermediate,           orders       WHERE  

Re: [GENERAL] [Newbie] UPDATE based on other table content

2009-10-29 Thread Daniel Chiaramello
Thom Brown a écrit : ... 2009/10/29 Daniel Chiaramello daniel.chiarame...@golog.net: Never mind, I found how finally: UPDATE product SET qty = qty+s_count FROM ( SELECT intermediate.product_id, count(*) AS s_count FROM intermediate,

[GENERAL] Sql Update Sentence

2009-05-23 Thread mariolos
hello to all!!! i have a quiestion and problem, i need replace a value from a field with other value, i try using this sql sentence: update packing_acum set corr=corr + 200) BETWEEN 26821 AND 27340 and extract(year from fec_prod) = 2009 AND cod_packing between 2321 and 2327 but this error

Re: [GENERAL] Sql Update Sentence

2009-05-23 Thread Adrian Klaver
On Saturday 23 May 2009 12:13:58 pm mariolos wrote: hello to all!!! i have a quiestion and problem, i need replace a value from a field with other value, i try using this sql sentence: Is this the entire actual SQL statement? If so see below. update packing_acum set corr=corr + 200) BETWEEN

Re: [GENERAL] Sql Update Sentence

2009-05-23 Thread Martijn van Oosterhout
On Sat, May 23, 2009 at 03:13:58PM -0400, mariolos wrote: hello to all!!! i have a quiestion and problem, i need replace a value from a field with other value, i try using this sql sentence: update packing_acum set corr=corr + 200) BETWEEN 26821 AND 27340 and extract(year from fec_prod) =

[GENERAL] plpgsql: UPDATE...Returning in FOR loop

2009-03-02 Thread Raymond O'Donnell
Hi all, I'm wondering if it's possible to use UPDATE...RETURNING, instead of SELECT, in a FOR loop like this: for rec in update recipients set batch_id = TheID where recip_id = any ( select recip_id from recipients where msg_id = TheMessage and recip_type = TheType and

Re: [GENERAL] plpgsql: UPDATE...Returning in FOR loop

2009-03-02 Thread Tom Lane
Raymond O'Donnell r...@iol.ie writes: I'm wondering if it's possible to use UPDATE...RETURNING, instead of SELECT, in a FOR loop like this: ... I'm guessing that this isn't possible, because when I try it I get the following error: gti_messaging= select recipients_for_delivery(5, 'Email',

Re: [GENERAL] plpgsql: UPDATE...Returning in FOR loop

2009-03-02 Thread Sam Mason
On Mon, Mar 02, 2009 at 07:34:55PM +, Raymond O'Donnell wrote: when I try it I get the following error: I've never tried doing things like this before, but it looks as though everything is working. I'd interpret your error message: gti_messaging= select recipients_for_delivery(5, 'Email',

Re: [GENERAL] plpgsql: UPDATE...Returning in FOR loop

2009-03-02 Thread Raymond O'Donnell
On 02/03/2009 20:19, Tom Lane wrote: Well, that has nothing to do with UPDATE RETURNING; it's apparently failing here: rec recipients; I suppose recipients is a composite type one of whose columns is of a NOT NULL domain. Best advice is don't do that --- not-null domains Thanks Tom

Re: [GENERAL] Slow update

2009-02-15 Thread Herouth Maoz
Alban Hertroys wrote: On Feb 9, 2009, at 2:07 PM, Grzegorz Jaśkiewicz wrote: On Mon, Feb 9, 2009 at 12:50 PM, Herouth Maoz hero...@unicell.co.il wrote: I hope someone can clue me in based on the results of explain analyze. Did you have a chance to run vmstat on it, and post it here ? Maybe

Re: [GENERAL] Slow update

2009-02-09 Thread Herouth Maoz
Filip Rembiałkowski wrote: 2009/1/21 Herouth Maoz hero...@unicell.co.il mailto:hero...@unicell.co.il Hello. I have a daily process that synchronizes our reports database from our production databases. In the past few days, it happened a couple of times that an update

Re: [GENERAL] Slow update

2009-02-09 Thread Grzegorz Jaśkiewicz
On Mon, Feb 9, 2009 at 12:50 PM, Herouth Maoz hero...@unicell.co.il wrote: I hope someone can clue me in based on the results of explain analyze. Did you have a chance to run vmstat on it, and post it here ? Maybe - if db resides on the same disc with everything else, something (ab)uses that

Re: [GENERAL] Slow update

2009-02-09 Thread Herouth Maoz
Grzegorz Jaśkiewicz wrote: On Mon, Feb 9, 2009 at 12:50 PM, Herouth Maoz hero...@unicell.co.il wrote: I hope someone can clue me in based on the results of explain analyze. Did you have a chance to run vmstat on it, and post it here ? Maybe - if db resides on the same disc with

Re: [GENERAL] Slow update

2009-02-09 Thread Alban Hertroys
On Feb 9, 2009, at 2:07 PM, Grzegorz Jaśkiewicz wrote: On Mon, Feb 9, 2009 at 12:50 PM, Herouth Maoz hero...@unicell.co.il wrote: I hope someone can clue me in based on the results of explain analyze. Did you have a chance to run vmstat on it, and post it here ? Maybe - if db resides on

Re: [GENERAL] Slow update

2009-01-22 Thread Marc Mamin
, Marc From: Herouth Maoz [mailto:hero...@unicell.co.il] Sent: Wednesday, January 21, 2009 12:50 PM To: Marc Mamin Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Slow update Marc Mamin wrote: Hello, - did you vacuum your

Re: [GENERAL] Slow update

2009-01-22 Thread Scott Marlowe
On Wed, Jan 21, 2009 at 9:36 AM, Herouth Maoz hero...@unicell.co.il wrote: I have a test machine - but the data in there is test data, and it's a slower machine. A testing environment is good for development, but can hardly be used to really simulate the production machine for performance.

[GENERAL] Slow update

2009-01-21 Thread Herouth Maoz
Hello. I have a daily process that synchronizes our reports database from our production databases. In the past few days, it happened a couple of times that an update query took around 7-8 hours to complete, which seems a bit excessive. This is the query: UPDATE rb SET service =

Re: [GENERAL] Slow update

2009-01-21 Thread Marc Mamin
[mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Herouth Maoz Sent: Wednesday, January 21, 2009 10:30 AM To: pgsql-general@postgresql.org Subject: [GENERAL] Slow update Hello. I have a daily process that synchronizes our reports database from our production databases. In the past few days

Re: [GENERAL] Slow update

2009-01-21 Thread Herouth Maoz
Marc Mamin wrote: Hello, - did you vacuum your tables recently ? - What I miss in your query is a check for the rows that do not need to be udated: AND NOT (service = b.service AND status = b.status AND has_notification = gateway_id NOT IN (4,101,102)

Re: [GENERAL] Slow update

2009-01-21 Thread Herouth Maoz
Filip Rembiałkowski wrote: 1. which postgres version? 8.3.1 2. can you post results of EXPLAIN ANALYZE (please note it actually executes the query)? Well, if it executes the query it's a problem. I might be able to do so during the weekend, when I can play with the scripts and get away with

Re: [GENERAL] Slow update

2009-01-21 Thread Filip Rembiałkowski
2009/1/21 Herouth Maoz hero...@unicell.co.il Hello. I have a daily process that synchronizes our reports database from our production databases. In the past few days, it happened a couple of times that an update query took around 7-8 hours to complete, which seems a bit excessive. This is

Re: [GENERAL] Slow update

2009-01-21 Thread Grzegorz Jaśkiewicz
On Wed, Jan 21, 2009 at 12:55 PM, Herouth Maoz hero...@unicell.co.il wrote: Well, if it executes the query it's a problem. I might be able to do so during the weekend, when I can play with the scripts and get away with failures, but of course there is less data in the tables then. you should

Re: [GENERAL] Slow update

2009-01-21 Thread Sam Mason
On Wed, Jan 21, 2009 at 02:55:00PM +0200, Herouth Maoz wrote: Filip Rembiakowski wrote: 2. can you post results of EXPLAIN ANALYZE (please note it actually executes the query)? Well, if it executes the query it's a problem. You can wrap an EXPLAIN ANALYSE up in BEGIN;...ROLLBACK;. That

Re: [GENERAL] Slow update

2009-01-21 Thread Herouth Maoz
Grzegorz Jaśkiewicz wrote: On Wed, Jan 21, 2009 at 12:55 PM, Herouth Maoz hero...@unicell.co.il wrote: Well, if it executes the query it's a problem. I might be able to do so during the weekend, when I can play with the scripts and get away with failures, but of course there is less data

[GENERAL] Can update triggers detect the column in the update statement?

2008-10-06 Thread Ben Chobot
Say I have: create t (c1 int not null, c2 int); Is it possible to create an update trigger on t such updates will only be allowed if the update statement explicitly sets c1, even if the new value is the same? (I'm trying to write a change log system where the users are application

Re: [GENERAL] Can update triggers detect the column in the update statement?

2008-10-06 Thread Tom Lane
Ben Chobot [EMAIL PROTECTED] writes: Say I have: create t (c1 int not null, c2 int); Is it possible to create an update trigger on t such updates will only be allowed if the update statement explicitly sets c1, even if the new value is the same? No. A trigger can only tell whether the

Re: [GENERAL] Can update triggers detect the column in the update statement?

2008-10-06 Thread Ben Chobot
On Oct 6, 2008, at 5:53 PM, Tom Lane wrote: Ben Chobot [EMAIL PROTECTED] writes: Say I have: create t (c1 int not null, c2 int); Is it possible to create an update trigger on t such updates will only be allowed if the update statement explicitly sets c1, even if the new value is the

Re: [GENERAL] Can update triggers detect the column in the update statement?

2008-10-06 Thread Martin Gainty
: [GENERAL] Can update triggers detect the column in the update statement? Date: Mon, 6 Oct 2008 17:24:37 -0700 Say I have: create t (c1 int not null, c2 int); Is it possible to create an update trigger on t such updates will only be allowed if the update statement explicitly sets c1, even

Re: [GENERAL] Cannot update table with OID with linked server in SQl Server

2008-05-08 Thread Ken Allen
Yes the table does have a primary key defined. -Original Message- From: Adrian Klaver [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 06, 2008 7:07 PM To: Ken Allen; pgsql-general@postgresql.org Subject: Re: [GENERAL] Cannot update table with OID with linked server in SQl Server

[GENERAL] Cannot update table with OID with linked server in SQl Server

2008-05-06 Thread Ken Allen
I have a linked server on SQL server 2005. I can update or write to a table in Postgres that does not have a OID. But the Table I have has an OID and I cannot write or update to that table. Anyone have any ideas.

<    1   2   3   4   5   >