Re: [GENERAL] Substitute a variable in PL/PGSQL.

2008-07-23 Thread artacus
You can do it in straight sql like so. SELECT (array[col1, col2, col3, col4, col5, col6, col7, col8, col9, col10])[i] FROM test t, generate_series(1,10) i Art -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription:

Re: [GENERAL] pg_query transaction: auto rollback? begin or start?? commit or end???

2008-07-23 Thread Karsten Hilbert
On Wed, Jul 23, 2008 at 01:15:30PM +1000, Chris wrote: Now *any* error inside transaction will trigger auto rollback for *all* inserts so I don't need to explicitly issue conditional rollback? Also is begin/commit transaction == start/end transaction?? What if something gets an invalid

[GENERAL] plpgsql functions or queries

2008-07-23 Thread Artis Caune
Is it safe to use plpgsql functions with 'security definer'? For example we have table for spamassassin preferences, and user spamassassin. I don't want spamassassin user to see user database (passwords, ...) So I use function: CREATE OR REPLACE FUNCTION get_sa_preferences( VARCHAR ) RETURNS

[GENERAL] High activity short table and locks

2008-07-23 Thread Guillaume Bog
Hi! We have been using postgresql since a while without problems. But now I find we experience some slowness and the weird thing is that it seems to happen because of a very short table (less than 200 lines), called lockers (see below it's structure). This table is accessed very often by a lot

Re: [GENERAL] Substitute a variable in PL/PGSQL.

2008-07-23 Thread Klint Gore
Steve Martin wrote: I am trying to create a PL/PGSQL function to return the values of the fields in a record, e.g. 1 value per row in the output of the function. How do you substitute a variable? CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF text AS $$ DECLARE ted varchar;

Re: [GENERAL] High activity short table and locks

2008-07-23 Thread Richard Huxton
Guillaume Bog wrote: It seems I'm a bit stuck here. I'd appreciate some help. My main general question is how to handle very small but hot status table that has to be updated every 30 seconds by 100 different persons, read and updated from many sides, and also joined with some more common tables

Re: [GENERAL] inconsistent program behavior, fresh eyes needed

2008-07-23 Thread Emil Pedersen
I got some lint/splint output off-list (thanks!) but couldn't find anything with related to the problem. I did find (and fixed) an unrelated error in the python version that prevented it to work on the annonynized input files though. Anyone other ideas on this problem or what can be done to

[GENERAL] A couple of newbie questions ...

2008-07-23 Thread admin
I've worked as a web developer on mostly small business websites for the past seven years, and while I've had some limited experience with older versions of PostgreSQL (7.* ??), I've mostly used MySQL all this time. I now work for local govt and am building a large intranet-like system which

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Raymond O'Donnell
On 23/07/2008 10:48, admin wrote: So anyway, life story aside, I have a couple of very newbie questions after tinkering with PostgreSQL 8.1.9 for a day converting some PHP/MySQL code: Hi there, You should consider upgrading to 8.3 if you can - there are significant performance improvements.

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Raymond O'Donnell
On 23/07/2008 11:01, Raymond O'Donnell wrote: On 23/07/2008 10:48, admin wrote: 1. Is a SEQUENCE what I use instead of auto_increment? Yes. The easiest thing is to define the column as type SERIAL - this will create the sequence for you and associate it with the column. Alternatively, you

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Craig Ringer
admin wrote: I'm convinced that PostgreSQL's performance is not an issue (both because it's improved and traffic will be relatively low anyway) It's really rather solid in performance terms anyway, especially for non-trivial workloads where data consistency and reliability are important.

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Karsten Hilbert
On Wed, Jul 23, 2008 at 07:18:15PM +0930, admin wrote: 1. Is a SEQUENCE what I use instead of auto_increment? Yes. Perhaps better use it indirectly with (BIG)SERIAL: create table foo ( pk (big)serial ); 2. Does this work in PostgreSQL: INSERT INTO table VALUES ('x','y','z') Yes,

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread A. Kretschmer
am Wed, dem 23.07.2008, um 19:18:15 +0930 mailte admin folgendes: 1. Is a SEQUENCE what I use instead of auto_increment? Yes. 2. Does this work in PostgreSQL: INSERT INTO table VALUES ('x','y','z') or do I need to do this INSERT INTO table (fld_x,fld_y,fld_z) VALUES ('x','y','z')

Re: [GENERAL] High activity short table and locks

2008-07-23 Thread Guillaume Bog
On Wed, Jul 23, 2008 at 4:50 PM, Richard Huxton [EMAIL PROTECTED] wrote: Guillaume Bog wrote: It seems I'm a bit stuck here. I'd appreciate some help. My main general question is how to handle very small but hot status table that has to be updated every 30 seconds by 100 different persons,

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Albe Laurenz
admin wrote: So anyway, life story aside, I have a couple of very newbie questions after tinkering with PostgreSQL 8.1.9 for a day converting some PHP/MySQL code: Here I have to ask the obvious thing: Why not a more current version? 1. Is a SEQUENCE what I use instead of auto_increment?

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Scott Marlowe
On Wed, Jul 23, 2008 at 3:48 AM, admin [EMAIL PROTECTED] wrote: I'm convinced that PostgreSQL's performance is not an issue (both because it's improved and traffic will be relatively low anyway), and that the benefits of PostgreSQL's advanced features are too good to ignore. I'm hoping to

Re: [GENERAL] pg_query transaction: auto rollback? begin or start?? commit or end???

2008-07-23 Thread Bill Wordsworth
Thanks Chris and Karsten. I still don't quite understand why invalid state/record-mismatch would also not trigger auto rollback. How can I even include something *outside* a transaction *inside* it- shouldn't everything between begin and end be subject to auto rollback no matter what? Also what

[GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
The data set I am working with has a very uneven distribution. I had to to set random_page_cost = 0.75 to get good plans. However, that first tries bitmap scans which perform very poorly. Is there a way to have the planner to favor index scans and disfavor bitmap scans? Is my best choice to just

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Shane Ambler
Raymond O'Donnell wrote: 1. Is a SEQUENCE what I use instead of auto_increment? Yes. The easiest thing is to define the column as type SERIAL - this will create the sequence for you and associate it with the column. Alternatively, you can create the sequence by hand, create the column as an

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Shane Ambler
Craig Ringer wrote: INSERT INTO table (fld_y,fld_z) VALUES ('y','z') which is really doing: INSERT INTO table (fld_x, fld_y,fld_z) VALUES (DEFAULT, 'y','z') To be honest I hadn't seen the use of INSERT INTO table (fld_x, fld_y,fld_z) VALUES (DEFAULT, 'y','z') before, I have always gone

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Tom Lane
Francisco Reyes [EMAIL PROTECTED] writes: So far in this data set almost every time bitmap scans are used the queries do worse, much worse. I had one extreme case where a sequential scan would finish in 20 minutes and the same query using bitmap scans would take over a day to finish. That's

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Craig Ringer
Shane Ambler wrote: INSERT INTO table (fld_x, fld_y,fld_z) VALUES (DEFAULT, 'y','z') To be honest I hadn't seen the use of INSERT INTO table (fld_x, fld_y,fld_z) VALUES (DEFAULT, 'y','z') before, I have always gone with INSERT INTO table (fld_x, fld_y,fld_z) VALUES (NULL, 'y','z') ...

Re: [GENERAL] Substitute a variable in PL/PGSQL.

2008-07-23 Thread Merlin Moncure
On Wed, Jul 23, 2008 at 4:08 AM, Klint Gore [EMAIL PROTECTED] wrote: Steve Martin wrote: I am trying to create a PL/PGSQL function to return the values of the fields in a record, e.g. 1 value per row in the output of the function. How do you substitute a variable? CREATE OR REPLACE

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
On 12:40 pm 07/23/08 Tom Lane [EMAIL PROTECTED] wrote: That's fairly hard to believe. Care to offer some details? I will dig that actual project and run explain analyze. Will likely not have it till middle of next week though because of a monthly process starting out Friday. However, I do

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Francisco Reyes
On 12:00 pm 07/23/08 Shane Ambler [EMAIL PROTECTED] wrote: INSERT INTO table (fld_y,fld_z) VALUES ('y','z') I believe that is the most common way of doing it. which is really doing: INSERT INTO table (fld_x, fld_y,fld_z) VALUES (DEFAULT, 'y','z') Correct. So either one should be fine.

[GENERAL] mac install question

2008-07-23 Thread [EMAIL PROTECTED]
Please excuse my lack of mac knowledge. I installed postgresql 8.3 using the mac os x 1 click installer onto my brand new powerbook. The install appeared to go very smooth. If I go to Postgresql under Applications it appears as if I can start and stop postgres and open pgadmin. I even

Re: [GENERAL] mac install question

2008-07-23 Thread Douglas McNaught
On Wed, Jul 23, 2008 at 1:58 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Please excuse my lack of mac knowledge. I installed postgresql 8.3 using the mac os x 1 click installer onto my brand new powerbook. The install appeared to go very smooth. If I go to Postgresql under Applications

Re: [GENERAL] mac install question

2008-07-23 Thread [EMAIL PROTECTED]
Date: Wed, 23 Jul 2008 14:12:45 -0400 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [GENERAL] mac install question CC: pgsql-general@postgresql.org On Wed, Jul 23, 2008 at 1:58 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Please excuse my lack of mac knowledge. I

Re: [GENERAL] mac install question

2008-07-23 Thread Douglas McNaught
On Wed, Jul 23, 2008 at 2:19 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Well I got it from a link on postgresql.org. Of course it does say that it is a beta installer. http://www.postgresql.org/download/macosx Well, hopefully the maintainer reads this mailing list then. :) -Doug --

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Scott Marlowe
On Wed, Jul 23, 2008 at 11:43 AM, Francisco Reyes [EMAIL PROTECTED] wrote: On 12:40 pm 07/23/08 Tom Lane [EMAIL PROTECTED] wrote: That's fairly hard to believe. Care to offer some details? I will dig that actual project and run explain analyze. Will likely not have it till middle of next

Re: [GENERAL] mac install question

2008-07-23 Thread dpage
He does, though he's currently on vacation, being forced to top-post in the gmail mobile interface :-p Can the OP send me (privately) the bitrock_installer log from /tmp please? Thanks, Dave On 7/23/08, Douglas McNaught [EMAIL PROTECTED] wrote: On Wed, Jul 23, 2008 at 2:19 PM, [EMAIL PROTECTED]

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Tino Wildenhain
Shane Ambler wrote: Raymond O'Donnell wrote: ... INSERT INTO table (fld_y, fld_z) VALUES ('y', 'z'); Another way is INSERT INTO table VALUES (NULL,'y','z') of course you meant: INSERT INTO table VALUES (DEFAULT,'y','z') since Null would be wrongly insert NULL value instead of using the

[GENERAL] Equality search on timestamp value returns no rows

2008-07-23 Thread Keaton Adams
PostgreSQL 8.1.4 RHEL 4.x So we have run into an interesting problem I want to know if anyone else has encountered before. We have a scheduler process that 'hangs' on occasion and we have isolated the issue to Postgres not returning any records when there are actual records to return. Here

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
On 2:23 pm 07/23/08 Scott Marlowe [EMAIL PROTECTED] wrote: However, I do have a current example where bitmap index scan was 3 times worse. What is your work_mem set to? For the examples that I posted it is work_mem = 64MB -- Sent via pgsql-general mailing list

Re: [GENERAL] mac install question

2008-07-23 Thread A.M.
On Jul 23, 2008, at 2:19 PM, [EMAIL PROTECTED] wrote: Date: Wed, 23 Jul 2008 14:12:45 -0400 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [GENERAL] mac install question CC: pgsql-general@postgresql.org On Wed, Jul 23, 2008 at 1:58 PM, [EMAIL PROTECTED] [EMAIL PROTECTED]

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Tom Lane
Francisco Reyes [EMAIL PROTECTED] writes: SET ENABLE_SEQSCAN TO OFF; SET ENABLE_BITMAPSCAN TO OFF; Aggregate (cost=25665216.10..25665216.11 rows=1 width=12) (actual time=3088.894..3088.896 rows=1 loops=1) - Nested Loop (cost=0.00..25662307.70 rows=387785 width=12) (actual

Re: [GENERAL] mac install question

2008-07-23 Thread dpage
Thanks for the log. It shows that the otool utility couldn't be found (which should be a fatal error but that's another issue. Is the otool program on your system anywhere? Afaik, it should be on any Mac, but maybe it's part of xcode (i hope not- can anyone confirm?) In any case, re-running the

Re: [GENERAL] mac install question

2008-07-23 Thread dpage
it's a command line utility. On 7/23/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Frankly i have no idea what otool is? Date: Wed, 23 Jul 2008 20:45:23 +0100 From: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: Re: [GENERAL] mac install question CC: pgsql-general@postgresql.org

Re: [GENERAL] mac install question

2008-07-23 Thread dpage
that'll make it work, but doesn't fix the problem. :-( On 7/23/08, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Well scott's suggestion seemed to work: Ryan, Try setting: export DYLD_LIBRARY_PATH=/Library/PostgreSQL/8.3/lib:$DYLD_LIBRARY_PATH and running the command

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
On 3:37 pm 07/23/08 Tom Lane [EMAIL PROTECTED] wrote: Francisco Reyes [EMAIL PROTECTED] writes: SET ENABLE_SEQSCAN TO OFF; SET ENABLE_BITMAPSCAN TO OFF; Aggregate (cost=25665216.10..25665216.11 rows=1 width=12) (actual time=3088.894..3088.896 rows=1 loops=1) - Nested Loop

Re: [GENERAL] Equality search on timestamp value returns no rows

2008-07-23 Thread Tom Lane
Keaton Adams [EMAIL PROTECTED] writes: Any ideas why the equality search wouldn't work in the first case, but after reloading the table data it works just fine? I think you're using floating-point timestamps and encountering a roundoff issue. regards, tom lane --

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
Table layouts: historical Column | Type |Modifiers ---+--+-- record_id | integer | not null default nextval('historical_record_id_seq'::regclass) f3| integer

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Tom Lane
Francisco Reyes [EMAIL PROTECTED] writes: On 3:37 pm 07/23/08 Tom Lane [EMAIL PROTECTED] wrote: You might be more likely to get a sane plan if you had an index on join_ids.customer_id. There is an index in join_ids: joinids_customerids_joinid btree (customer_id, joinid) WITH (fillfactor=98)

Re: [GENERAL] Any way to favor index scans, but not bitmap index scans?

2008-07-23 Thread Francisco Reyes
On 4:12 pm 07/23/08 Francisco Reyes [EMAIL PROTECTED] wrote: Also, that plan is only 3 seconds. Minor update. A co-worker is using another DB.. and re-running my query after he did his work.. now the query using the index scans takes 2 minutes instead of 3 seconds. 3 seconds was likely data

Re: [GENERAL] mac install question

2008-07-23 Thread Tom Lane
[EMAIL PROTECTED] writes: Thanks for the log. It shows that the otool utility couldn't be found (which should be a fatal error but that's another issue. Is the otool program on your system anywhere? Afaik, it should be on any Mac, but maybe it's part of xcode (i hope not- can anyone

Re: [GENERAL] mac install question

2008-07-23 Thread Dave Page
On 23 Jul 2008, at 21:47, Tom Lane [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] writes: Thanks for the log. It shows that the otool utility couldn't be found (which should be a fatal error but that's another issue. Is the otool program on your system anywhere? Afaik, it should be on any Mac,

[GENERAL] How support more native locale in one cluster?

2008-07-23 Thread Michal Seidl
Hi, I can not figure out how to solve the problem with LOCALE. Example: - 3 tables, each of them with a text or varchar column. - The first table with text in German - The second table with text in Czech - the third one with text in English How to force Postgre to use correct locale for ORDER

Re: [GENERAL] How support more native locale in one cluster?

2008-07-23 Thread Karsten Hilbert
On Wed, Jul 23, 2008 at 11:49:38PM +0200, Michal Seidl wrote: Hi, I can not figure out how to solve the problem with LOCALE. Example: - 3 tables, each of them with a text or varchar column. - The first table with text in German - The second table with text in Czech - the third one with

Re: [GENERAL] How support more native locale in one cluster?

2008-07-23 Thread Alvaro Herrera
Michal Seidl escribió: Hi, I can not figure out how to solve the problem with LOCALE. Example: - 3 tables, each of them with a text or varchar column. - The first table with text in German - The second table with text in Czech - the third one with text in English You cannot do this in

[GENERAL] contrib catalogs

2008-07-23 Thread Kevin Neufeld
This might seem like a silly question, but what are the implications of PostgreSQL allowing developers to create custom catalogs? For example, PostgreSQL currently uses the pg_catalog schema to store system catalogs / relations / functions / etc. Has thought gone into extending the scope to

[GENERAL] cast affects use of indexes ?

2008-07-23 Thread Alex Vinogradovs
Guys, I've got a table with an indexed column of a numeric user type (implemented in C). When I run a select on that table in a form of : select * from sometable where column = 89464; sequential scan is used... When I rewrite the query to use cast like this : select * from sometable where

[GENERAL] problem installing RPMs on RHEL5

2008-07-23 Thread Garber, Mikhail
I installed Postgresql from RedHat 5EL RPMS from the site. When I try to start it as a service, it fails and pgstartup.log contains one record per startup attempt stating: runuser: warning: cannot change directory to /dev/null: Not a directory. Thanks!

Re: [GENERAL] mac install question

2008-07-23 Thread Craig Ringer
Dave Page wrote: The linker hardcodes library paths into exes and libs. We examine these paths at install time using otool and rewrite them from the staging paths on the build machine to whatever directory the user chose to install to using install_name_tool(1). Yep, the mac linker seems to

Re: [GENERAL] pg_query transaction: auto rollback? begin or start?? commit or end???

2008-07-23 Thread Chris
Bill Wordsworth wrote: Thanks Chris and Karsten. I still don't quite understand why invalid state/record-mismatch would also not trigger auto rollback. If you should have put id 5 instead of id 2 as a foreign key, how is the database going to know the difference? Both are valid id's and valid

Re: [GENERAL] mac install question

2008-07-23 Thread Shane Ambler
[EMAIL PROTECTED] wrote: Is the otool program on your system anywhere? Afaik, it should be on any Mac, but maybe it's part of xcode (i hope not- can anyone confirm?) I have a few installs here. otool is included inside /Developer/usr/bin my working 10.4 that the dev tools is installed on

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Artacus
This is one of the many SQL bad habits you've likely picked up from using MySQL. I'd highly suggest reading the pgsql users manual cover to cover, you'll pick up a lot of good info on how to drive postgresql. Other things that work in mysql but fail in pgsql include inserting things that are

Re: [GENERAL] A couple of newbie questions ...

2008-07-23 Thread Scott Marlowe
On Wed, Jul 23, 2008 at 10:22 PM, Artacus [EMAIL PROTECTED] wrote: This is one of the many SQL bad habits you've likely picked up from using MySQL. I'd highly suggest reading the pgsql users manual cover to cover, you'll pick up a lot of good info on how to drive postgresql. Other things

Re: [GENERAL] mac install question

2008-07-23 Thread Tom Lane
Dave Page [EMAIL PROTECTED] writes: What are you using it for that you need it to be present at install time? The linker hardcodes library paths into exes and libs. We examine these paths at install time using otool and rewrite them from the staging paths on the build machine to whatever

Re: [GENERAL] contrib catalogs

2008-07-23 Thread Tom Lane
Kevin Neufeld [EMAIL PROTECTED] writes: This might seem like a silly question, but what are the implications of PostgreSQL allowing developers to create custom catalogs? For example, PostgreSQL currently uses the pg_catalog schema to store system catalogs / relations / functions / etc. Has