[GENERAL] left outer join without rows from left table

2009-02-16 Thread Scara Maccai
Hi all, I want to get data from these tables: TABID integer id, name varchar example values: 1 'id1' 2 'id2' [...] TABA integer id, timestamp t, integer a example values: 1 '2009-02-13 00:00:00' 10 1 '2009-02-13 02:00:00' 19 TABB integer id, timestamp t, integer b example values: 1 '2009-02-13

[GENERAL] ask: select right(column) ???

2009-02-16 Thread hendra kusuma
Dear all, I have simple question I tried following code select right(column, number_of_character) from table but it didn't work, saying that pg doesn't have the function is there any way to achieve such output? honestly I have no idea that such simple feature doesn't exist in postgresql or am

Re: [GENERAL] ask: select right(column) ???

2009-02-16 Thread Ludwig Kniprath
Hello Hendra, there is no function right(column, n-Chars), but you can use substring(column-name from offset for num_chars) in combination with char_length for getting the right-n-characters as f. e.: select substring(column from (char_length(column) - 3) for 4) from table Ludwig Dear all,

[GENERAL] idle DB and resources

2009-02-16 Thread Ivan Sergio Borgonovo
We've one site already in production and another one that will take its birth from the previous one. Since editors have to prune and adapt content from the previous one I'm going to duplicate the DB and put it online on the same box and let editors do their job. Later we may decide to move it on

Re: [GENERAL] left outer join without rows from left table

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 12:15:47AM -0800, Scara Maccai wrote: select * from TABID left outer join TABA on (id) left outer join TABB on TABB.id = TABID.id and TABA.t = TABB.t So, basically, all the rows from table TABID joined with both table TABA and TABB. The problem is that some times TABB

Re: [GENERAL] ask: select right(column) ???

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 03:21:20PM +0700, hendra kusuma wrote: select right(column, number_of_character) from table [..] honestly I have no idea that such simple feature doesn't exist in postgresql or am I wrong? since I look at SQL Key Words table and it's written as reserved AFAIK, it's

Re: [GENERAL] ask: select right(column) ???

2009-02-16 Thread Lennin Caro
I have simple question I tried following code select right(column, number_of_character) from table but it didn't work, saying that pg doesn't have the function is there any way to achieve such output? honestly I have no idea that such simple feature doesn't exist in postgresql or

Re: [GENERAL] idle DB and resources

2009-02-16 Thread Craig Ringer
Ivan Sergio Borgonovo wrote: Meanwhile we will have 2 large DB, one of them being nearly idle. Is the idle DB going to have any impact on performance? I'm far from an expert here, but AFAIK it shouldn't have much impact. That does depend, though, on just how idle it really is, and how much of

Re: [GENERAL] left outer join without rows from left table

2009-02-16 Thread Scara Maccai
Thank you: that's exactly what I needed. I think you want to use a full outer join with slightly unusual bracketing: SELECT t.id, COALESCE(a.t,b.t) AS t, a.a, b.b FROM tabid t LEFT JOIN ( taba a FULL OUTER JOIN tabb b ON (a.id,a.t) = (b.id,b.t)) ON t.id =

Re: [GENERAL] clearing the buffer cache

2009-02-16 Thread Chris Mayfield
With recent versions of Linux you can flush the system's buffer cache by doing: # echo 3 /proc/sys/vm/drop_caches You can also try something like this: http://wiki.services.openoffice.org/wiki/Cold-start-simulator Shutting down the server and running fillmem has worked for me, but that

Re: [GENERAL] ask: select right(column) ???

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 07:10:11AM -0800, Lennin Caro wrote: you can use the substring function, like this select 'test123',substring('test123' from '...$') this return '123' Note that regexps are slower than substrings; as an example, I did: SELECT COUNT(s) FROM ( SELECT

Re: [GENERAL] clearing the buffer cache

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 11:09:59AM -0500, Chris Mayfield wrote: With recent versions of Linux you can flush the system's buffer cache by doing: # echo 3 /proc/sys/vm/drop_caches You can also try something like this: http://wiki.services.openoffice.org/wiki/Cold-start-simulator

Re: [GENERAL] partial unique index and the planner

2009-02-16 Thread Michal Politowski
On Sun, 15 Feb 2009 13:41:05 -0500, Tom Lane t...@sss.pgh.pa.us wrote: Michal Politowski mpol...@meep.pl writes: Is it normal that plans using a scan on a partial unique index estimate that much more than one row is returned? There isn't currently any special logic to recognize that

Re: [GENERAL] partial unique index and the planner

2009-02-16 Thread Alban Hertroys
On Feb 16, 2009, at 7:18 PM, Michal Politowski wrote: On Sun, 15 Feb 2009 13:41:05 -0500, Tom Lane t...@sss.pgh.pa.us wrote: Michal Politowski mpol...@meep.pl writes: Is it normal that plans using a scan on a partial unique index estimate that much more than one row is returned? There

Re: [GENERAL] Which SQL is the best for servers?

2009-02-16 Thread Troels Arvin
joel garry wrote: [...] Check out Oracle XE [...] As far as I know, Oracle has never issued any patches for Oracle XE. Given the stream of patches for the regular Oracle database, I fear that an Oracle XE installation will have a number of known bugs - possibly security bugs. Or? (Note:

Re: [GENERAL] clearing the buffer cache

2009-02-16 Thread Greg Smith
On Mon, 16 Feb 2009, Sam Mason wrote: On Mon, Feb 16, 2009 at 11:09:59AM -0500, Chris Mayfield wrote: You can also try something like this: http://wiki.services.openoffice.org/wiki/Cold-start-simulator might take too long in your situation of thousands of small queries. Why is this better

Re: [GENERAL] audit table

2009-02-16 Thread Robert Treat
On Thursday 12 February 2009 22:13:05 Craig Ringer wrote: Sim Zacks wrote: I want a trigger on every table that inserts the old row into an audit table (for updates and deletes). If the audit table was per table, then I could easily have a field of type that table and insert old into it.

Re: [GENERAL] Update table with random values from another table

2009-02-16 Thread Brent Wood
I'm not sure if that query will do what you want, but to make it work, one thing you might try, is to pre calculate the random values for each record, then order by those, eg: select trip_code, random() as rand from obs order by rand; works for me, so the following might for you: :

[GENERAL] transfering tables into other schema

2009-02-16 Thread Ivan Sergio Borgonovo
I've around 150-200 tables in the same schema. Some of them have pk/fk relationships and are referenced into functions (~20). One of them is surely referenced by most of those 20 and it is the largest. I'd like to move all the 200 tables to a new schema and leave that one in the public schema.