[GENERAL] uuid-ossp

2009-04-04 Thread Chris spotts
I’m brand new to Postgresql and working on moving an existing large DB into it. I’m trying to get uuid-ossp functions to work. I know the UUID type is installed, but I need the generate functions. I’ve installed postgresql-server and postgresql-contrib from the postgresql yum repos (working with

Re: [GENERAL] uuid-ossp

2009-04-04 Thread Chris spotts
Well, the only file that shows up is the uninstall file? Thats a little odd. Looks like I'll be rebuilding from source on monday...joyous. On Sat, 2009-04-04 at 11:40 -0400, Tom Lane wrote: > Chris spotts writes: > > I’m brand new to Postgresql and working on moving an > > ex

Re: [GENERAL] uuid-ossp

2009-04-04 Thread Chris spotts
Thanks, I got it installed from source and got uuid-ossp working. One of the easier installs from source for a major app that I've done. Appreciate the help. Chris On Sat, 2009-04-04 at 11:40 -0400, Tom Lane wrote: > Chris spotts writes: > > I’m brand new to Postgresql and wor

Re: [GENERAL] uuid-ossp

2009-04-04 Thread Chris spotts
Go figure, eh? It wasn't there when I installed the RHEL version. But its all good. Chris On Sat, 2009-04-04 at 22:28 +0300, Devrim GÜNDÜZ wrote: > On Sat, 2009-04-04 at 11:36 -0500, Chris spotts wrote: > > Well, the only file that shows up is the uninstall file? Thats a > >

[GENERAL] copy from with trigger

2009-04-05 Thread Chris spotts
I'm trying to copy from a tab delimited file. The dates inside the file are Unix timestamp style dates. I thought the following script would do the trick, but it just gives me an error saying ERROR: invalid input syntax for type timestamp: "1238736600" CONTEXT: COPY testtable line 1, column acq

Re: [GENERAL] copy from with trigger

2009-04-06 Thread Chris Spotts
Well that's a bummer, ok. Thanks. -Original Message- From: Tom Lane [mailto:t...@sss.pgh.pa.us] Sent: Sunday, April 05, 2009 10:27 PM To: Chris spotts Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] copy from with trigger Chris spotts writes: > I'm trying to co

Re: [GENERAL] copy from with trigger

2009-04-06 Thread Chris Spotts
That's a dead link for me. -Original Message- From: Alvaro Herrera [mailto:alvhe...@commandprompt.com] Sent: Monday, April 06, 2009 12:42 PM To: Chris Spotts Cc: 'Tom Lane'; pgsql-general@postgresql.org Subject: Re: [GENERAL] copy from with trigger Chris Spotts escribió:

Re: [GENERAL] INSERT or UPDATE TRIGGER

2009-04-07 Thread Chris Spotts
Not in regards to logging detail, but that function in general... I'm pretty new to postgres, so I could be totally wrong in this, but I think this thread http://archives.postgresql.org/pgsql-performance/2008-03/msg00204.php may pertain if you see some performance degradation with that trigger. Li

Re: [GENERAL] ERROR: syntax error at or near "IF"... why?

2009-05-01 Thread Chris Spotts
Could if be referencing the second IF..the one in your "END IF" that doesn't have a semicolon after it...? -Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of DaNieL Sent: Wednesday, April 29, 2009 9:54 AM To: pgsql-general@p

Re: [GENERAL] Handling large number of OR/IN conditions

2009-05-01 Thread Chris Spotts
A separate table for managing the relationships. One column for the manager and one for employee. Then you end up with a query like this. Select field1,field2 FROM table1 inner join relationships on table1.creator_user_id = relationships.employee WHERE relationships.manager = ? _ Fr

Re: [GENERAL] Converting Rows to Columns

2009-05-05 Thread Chris Spotts
It sounds like you want a crosstab query. There is probably (I don't know what version of postgres you're using) a contrib package called "tablefunc" that includes the crosstab functions you're looking for. _ From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgre

Re: [GENERAL] newbie table design question

2009-06-01 Thread Chris Spotts
I just finished doing something very close to this - not quite once per minute, but close. I started off with an array of integers and after about a month of it, I'm having to redesign my way out of it. It would have worked fine, but you just have to be sure that simple searches is all you're eve

Re: [GENERAL] type cast in index

2009-06-09 Thread Chris Spotts
>CREATE INDEX fecha_creacion_ordtrab ON orden_trabajo_cabecera USING btree >((time_stamp_creacion::date)); > >but in my postgresql 8.3 version i get this error: > >ERROR: functions in index expression must be marked IMMUTABLE If your time_stamp_creacion is a timestamp with time

Re: [GENERAL] help with data recovery from injected UPDATE

2009-06-11 Thread Chris Spotts
> It's a classic story. I'm volunteering about one day per month for > this project, learning SQL as I go. Priority was always given to the > "get it working" tasks and never the "make it safe" tasks. I had/have > grandiose plans to rewrite the whole system properly after I graduate. > Unfort

Re: [GENERAL] help with data recovery from injected UPDATE

2009-06-12 Thread Chris Spotts
> >> It's a classic story.  I'm volunteering about one day per month for > >> this project, learning SQL as I go.  Priority was always given to > the > >> "get it working" tasks and never the "make it safe" tasks.  I > had/have > >> grandiose plans to rewrite the whole system properly after I > gra

Re: [GENERAL] Question re 2 aggregates from 1 query

2009-06-18 Thread Chris Spotts
> > Is there any way to get count of docs & pages imported by date without > resorting to selecting from a select: [Spotts, Christopher] If I understand you correctly..? create table docs (id int8 primary key, imported_when timestamp ); create table pages (id int8 primary key, doc_id int8 not

Re: [GENERAL] Explaining functions.

2009-06-23 Thread Chris Spotts
> > is around 250 lines. > > What I normally do for benchmarking of complex functions is to > sprinkle the source with "raise notice '%', timeofday();" to figure > out where the bottlenecks are. Following that, I micro-optimize > problem queries or expressions outside of the function body in psql

Re: [GENERAL] Please suggest me on my table design (indexes!)

2009-06-23 Thread Chris Spotts
IMHO running queries on 23k'ish worth of rows isn't liable to stress any reasonably modern server, likely several times over that shouldn't either for simple "LIKE" searches. What kind of growth are you expecting? > -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsq

[GENERAL] planned recovery from a certain transaction

2009-06-25 Thread Chris Spotts
proc started. If we had the xid of the long running transaction, is there a better way to reset it right before that transaction happened? Restoring the backup is a lengthy process because several of the tables that are affected are rather large. Chris Spotts

Re: [GENERAL] planned recovery from a certain transaction

2009-06-25 Thread Chris Spotts
> > Assuming that the data is mostly created from whole cloth each > morning, it might do to have two dbs, and rename one to replace the > other when you're ready. Gives you 20 or so hours to discover a screw > up and still have the backup db before you toss it away to build the > next day For t

[GENERAL] Re planned recovery from a certain transaction

2009-06-25 Thread Chris Spotts
On Thu, 2009-06-25 at 21:59 +0100, Greg Stark wrote: > >> The transaction itself works flawlessly, but every once and awhile the data > >> the it uploads from comes in flawed and we have to find a way to reset it. > > If you can automate the tests for the flaws you can do the whole > transaction i

Re: [GENERAL] Switching from MySQL: ON DUPLICATE KEY UPDATE, plpgsql function

2009-07-01 Thread Chris Spotts
> > > > Wouldn't you just be looking for something like: > > > > BEGIN; > > EXECUTE 'insert into forums_readposts values ('...')'; > >EXCEPTION when unique_violation THEN > >EXECUTE 'update forums_readposts set lastpostread = > '...' '; > > END; > > The logic as i read you

Re: [GENERAL] now() + '4d' AT TIME ZONE issue

2009-07-08 Thread Chris Spotts
Try moving your "as future" SELECT now() AT TIME ZONE 'America/Toronto', CAST ((SELECT now() + '4d') AS TIMESTAMP) AT TIME ZONE 'America/Toronto' as future; > -Original Message- > From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general- > ow...@postgresql.org] On Be

[GENERAL] constraint checking on partitions

2009-07-09 Thread Chris Spotts
postgres=# select version(); version -- PostgreSQL 8.4.0 on x86_64-unknown-linux-gnu, compiled by GCC gcc (GCC) 3.4.6 20060404 (Red Hat 3.4.6-8.0.1), 64-bit Chris Spotts

Re: [GENERAL] constraint checking on partitions

2009-07-09 Thread Chris Spotts
> -Original Message- > From: Tom Lane [mailto:t...@sss.pgh.pa.us] > Sent: Thursday, July 09, 2009 1:52 PM > To: Chris Spotts > Cc: 'postgres list' > Subject: Re: [GENERAL] constraint checking on partitions > > "Chris Spotts" writes: > &

Re: [GENERAL] constraint checking on partitions

2009-07-09 Thread Chris Spotts
> > > If I ran a select * from A where date1 >= '2009-07-02' and date1 < > > '2009-07-15' then I would think it wouldn't check O. > [Spotts, Christopher] I oversimplified this too much - but I figured out what was happening. If you added the June table as well and added a separate NOT constrain

Re: [GENERAL] Re: [BUGS] BUG #4916: wish: more statistical functions (median, percentiles etc)

2009-07-13 Thread Chris Spotts
> > Details: > > > > In addition to the existing aggregate functions (avg, stddev etc), > it would > > be nice if postgres could return further information. For example, > the > > quartiles, percentiles, and median. [Spotts, Christopher] If you're interested in doing real stat work in postgres, tr

[GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
I had one simple query that kept crashing the connection. It crashes after several minutes. Tried restarting, it still error'd at the same place. Tried recreating the table it was selecting from, it still error'd at the same place. I rewrote the query with an ARRAY subselect and it finished fl

Re: [GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
> "Chris Spotts" writes: > > LOG: 0: autovacuum launcher process (PID 10264) was terminated > by > > signal 9: Killed > > Looks like the OOM killer is loose on your system. Disable memory > overcommit in the kernel and things will get better. > h

Re: [GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
> killed > > it after 15 minutes and no results...rather I tried to kill it, but > it looks > > like I'm going to have to -9 it... > > How big were the arrays you were trying to push around here? I tried > interrupting a similar query and it came right back; but if you were > building some really

Re: [GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
> >> How big were the arrays you were trying to push around here? > > > Like I'd said originally, there were no arrays that ended up being > more 4 > > elements long - all integers. The vast majority of them were 1 or 2 > long. > > Hm, maybe the problem is not so much array size as too many arra

Re: [GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
> -Original Message- > From: Tom Lane [mailto:t...@sss.pgh.pa.us] > Sent: Tuesday, July 21, 2009 12:16 PM > To: Chris Spotts > Cc: pgsql-general@postgresql.org > Subject: Re: [GENERAL] array_agg crash? > > "Chris Spotts" writes: > >> many groups

Re: [GENERAL] killing processes

2009-07-21 Thread Chris Spotts
> - type, and access into a varwidth array is O(n), so the sorting > - step you've got here is O(n^2). It might help to use unnest() > - instead of this handmade version of it ...) > > unnest() is 8.4 only, right? > > I'm actually probably just going to install R and use the median > function fr

Re: [GENERAL] array_agg crash?

2009-07-21 Thread Chris Spotts
Tom Lane wrote: "Chris Spotts" writes: many groups are you expecting in that query? Does the plan for the array_agg query show hash or group aggregation? GroupAggregate Huh, there's no reason it should take much memory then. Maybe you've found a m

Re: [GENERAL] How to execute external script from a TRIGGER or FUNCTION ?

2009-08-01 Thread Chris Spotts
After hours of search, I searched just some more and I think I found the solution, hope it can be useful to someone else : CREATE LANGUAGE plperlu; CREATE FUNCTION test_perl_external (integer) RETURNS boolean AS $$ $filename = '/tmp/somefile'; if (-e $filename) { return true; }

Re: [GENERAL] How ad an increasing index to a query result?

2009-10-14 Thread Chris Spotts
> > SELECT a, nextval('c') as b > FROM table1 > ORDER BY a DESC LIMIT 5; > > I.e., I want to pick the 5 largest entries from table1 and show them > alongside a new index column that tells the position of the entry. For > example: > > a | b > > 82 | 5 > 79 | 4 > 34 | 3 > 12 | 2 > 11 |

Re: [GENERAL] how to identify outliers

2009-10-28 Thread Chris Spotts
> > I'd agree, stddev is probably best and the following should do > something > reasonable for what the OP was asking: > > SELECT d.* > FROM data d, ( > SELECT avg(distance), stddev(distance) FROM data) x > WHERE abs(d.distance - x.avg) < x.stddev * 2; > [Spotts, Christopher] Statis