Re: [GENERAL] Incorrect results with NOT IN

2008-08-14 Thread Pavel Stehule
2008/8/15 Nick <[EMAIL PROTECTED]>: > I have a weird scenario on a table when I run this query... > > table1 has 1500 rows > table2 has 1200 rows > table2.id is a foreign key of table1.id > > SELECT COUNT(*) FROM table1 > WHERE id NOT IN ( > SELECT id FROM table2 > ); > > however, using NOT EXISTS

Re: [GENERAL] syntax error at or near "PERFORM"

2008-08-14 Thread Dale
On Aug 15, 2:14 pm, Dale <[EMAIL PROTECTED]> wrote: > Hi, > > When ever I try and call the PERFORM statement I get: > ERROR:  syntax error at or near "PERFORM" > even when I try executing something basic:  PERFORM (2 + 3); > > Any ideas please? > > Dale. I found my problem. Unfortunately PERFORM

[GENERAL] Default table permissions

2008-08-14 Thread Glen Parker
Hi all, Is there a way in Postgres to re-define, at the per user level, the default permission set applied to a table as it is created? Thanks! -Glen -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpre

[GENERAL] syntax error at or near "PERFORM"

2008-08-14 Thread Dale
Hi, When ever I try and call the PERFORM statement I get: ERROR: syntax error at or near "PERFORM" even when I try executing something basic: PERFORM (2 + 3); Any ideas please? Dale. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: h

[GENERAL] Incorrect results with NOT IN

2008-08-14 Thread Nick
I have a weird scenario on a table when I run this query... table1 has 1500 rows table2 has 1200 rows table2.id is a foreign key of table1.id SELECT COUNT(*) FROM table1 WHERE id NOT IN ( SELECT id FROM table2 ); however, using NOT EXISTS works SELECT COUNT(*) FROM table1 WHERE NOT EXISTS (

Re: [GENERAL] Query help

2008-08-14 Thread Brent Wood
If I read this correctly, you want the output sorted by config_id,start_day(day),start_time, thus: select config_id, start_day as day, start_time, end_time from config order by config_id, start_day, start_time; Cheers, Brent Wood >>> novice <[EMAIL PROTECTED]> 08/15/08 3:55 PM >>> Hi, I ha

Re: [GENERAL] Query help

2008-08-14 Thread novice
2008/8/15 novice <[EMAIL PROTECTED]>: > Hi, > I have a table > > select id, config_id, start_day, end_day, start_time, end_time from config; > > id | config_id | start_day | end_day | start_time | end_time > -+---+---+-++-- > 1 | 101 | Mon

Re: [GENERAL] [Q] DNS(bind) ER model

2008-08-14 Thread Andrew Sullivan
On Thu, Aug 14, 2008 at 04:20:14PM -0700, Roderick A. Anderson wrote: > Anyone aware of an ER model for holding name server records? What about a datatype? I have reason to believe that a company I used to work for implemented such a thing. There was some talk of releasing it, but I think there

Re: [GENERAL] Custom sort

2008-08-14 Thread Craig Ringer
Artacus wrote: > Can you define a custom sort in postgres? For instance in mysql, you > could do something like (I forget the exact syntax) > > ORDER BY FIND_IN_SET(column_name, ('one','two','three')) The simplest direct mapping would probably be a CASE statement (see the PostgreSQL documentation

Re: [GENERAL] Query help

2008-08-14 Thread Hui Xie
Hi , below can work? select config_id, start_day as day, start_time, end_time from config union select config_id, end_day as day, start_time, end_time from config Best Regards, Hui Xie --- Axisoft Co. Ltd. Zhuhai Branch Tel: (86) 0756-3612121 8858 novi

Re: [GENERAL] cannot use result of (insert .. returning)

2008-08-14 Thread Dale Harris
Hi Pavel, Thank you for your reply, but in this case the “INSERT INTO ... RETURNING field,... INTO STRICT variable,...;” is what works best for me currently. Regards, Dale Harris -Original Message- From: Pavel Stehule [mailto:[EMAIL PROTECTED] Sent: Thursday, 14 August

[GENERAL] Query help

2008-08-14 Thread novice
Hi, I have a table select id, config_id, start_day, end_day, start_time, end_time from config; id | config_id | start_day | end_day | start_time | end_time -+---+---+-++-- 1 | 101 | Mon | Sun | 08:30:00 | 18:00:00 2 |

Re: [GENERAL] [Q] DNS(bind) ER model

2008-08-14 Thread Martin Gainty
Mr Anderson-you use an enum to indicate your DNSrecordtype as in this MySQL exampleCREATE TABLE dns_updates| Field |Type | Null | Key | Default | Extra || id| int(11) | NO | PRI | NULL | auto_increment || bd_order_id| int(11) | YES | | NULL

[GENERAL] [Q] DNS(bind) ER model

2008-08-14 Thread Roderick A. Anderson
Anyone aware of an ER model for holding name server records? Working on the zone file data and I am getting close but keep running into the differences between MX records (with a priority) and the others that can hold either a domain/sub-domain/host name or an IP address depending on whether i

Re: [GENERAL] Postgres 8.3 is not using indexes

2008-08-14 Thread Schwaighofer Clemens
On Thu, Aug 14, 2008 at 20:27, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Am Thursday, 14. August 2008 schrieb Clemens Schwaighofer: > > Why is Postgres not using the indexes in the 8.3 installation. > > Might have something to do with the removal of some implicit casts. You > should show us y

Re: [GENERAL] Custom sort

2008-08-14 Thread Jeff Davis
On Thu, 2008-08-14 at 10:22 -0700, Artacus wrote: > Can you define a custom sort in postgres? For instance in mysql, you > could do something like (I forget the exact syntax) > > ORDER BY FIND_IN_SET(column_name, ('one','two','three')) > You can sort by any column, or arbitrary expression or fu

Re: [GENERAL] PostgreSQL arrays and DBD

2008-08-14 Thread SCassidy
[EMAIL PROTECTED] wrote on 08/14/2008 01:21:26 AM: > Hello. > > I create a table: > > CREATE TABLE groups ( > group_id serial PRIMARY KEY, > name varchar(64) UNIQUE NOT NULL, > guests integer[] DEFAULT '{}' > ) > > I add a new record to the table: > > INSERT INTO groups (name) VALUES ('M

[GENERAL] Experiences with BLOB + PostgreSQL

2008-08-14 Thread juliano . freitas
Hello, I'd like to ask you about some experience in managing huge databases which store mostly binary files. We're developing a system which is likely to grow up to terabytes in some years and I'd like to hear something from people who really administrate these kinds of databases. Please tell us

Re: [GENERAL] Custom sort

2008-08-14 Thread Bill Moran
In response to Artacus <[EMAIL PROTECTED]>: > Can you define a custom sort in postgres? For instance in mysql, you > could do something like (I forget the exact syntax) > > ORDER BY FIND_IN_SET(column_name, ('one','two','three')) You could do this by defining an ENUM for the values. ENUMs sort

Re: [GENERAL] Custom sort

2008-08-14 Thread Guillaume Lelarge
Artacus a écrit : > Can you define a custom sort in postgres? For instance in mysql, you > could do something like (I forget the exact syntax) > > ORDER BY FIND_IN_SET(column_name, ('one','two','three')) > I don't really know this syntax but isn't it something like : ORDER BY column_name='one'

[GENERAL] Custom sort

2008-08-14 Thread Artacus
Can you define a custom sort in postgres? For instance in mysql, you could do something like (I forget the exact syntax) ORDER BY FIND_IN_SET(column_name, ('one','two','three')) Art -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http

Re: [GENERAL] Strange query plan

2008-08-14 Thread Scott Marlowe
On Thu, Aug 14, 2008 at 8:48 AM, Gauthier, Dave <[EMAIL PROTECTED]> wrote: > Try this... > > Set default_statistics_target to be 1000 in postgres.conf then reboot > your pg server. "Analyze" the table. Try the query again. A reload is enough. I think you might have to disconnect and reconnect y

Re: [GENERAL] Newbie [CentOS 5.2] service postgresql initdb

2008-08-14 Thread Devrim GÜNDÜZ
On Tue, 2008-08-12 at 17:25 +0200, Daneel wrote: > > When I run > service postgresql initdb > I get > "se: [FAILED]". > However, /var/lib/pqsql/data is created and user postgres owns it. > > But then I run > service postgresql start > and the very same error occurs.. Anything in /var/lib/pgs

Re: [GENERAL] Strange query plan

2008-08-14 Thread Gauthier, Dave
Try this... Set default_statistics_target to be 1000 in postgres.conf then reboot your pg server. "Analyze" the table. Try the query again. If that fails, drop the index on (field1, field3) and recreate the other way around (field3, field1). Analyze again and try the query. -dave -Origi

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 18:47, Scott Marlowe <[EMAIL PROTECTED]> wrote: > What does "explain analyze select (your query here)" have to say? > Expalin analyze says it makes sequential scan on a table table1. On Thu, Aug 14, 2008 at 18:48, Gauthier, Dave <[EMAIL PROTECTED]> wrote: > Try this...

Re: [GENERAL] Strange query plan

2008-08-14 Thread Scott Marlowe
What does "explain analyze select (your query here)" have to say? -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Strange query plan

2008-08-14 Thread Thomas Burdairon
On 14 août 08, at 16:28, Dmitry Teslenko wrote: On Thu, Aug 14, 2008 at 17:55, Igor Neyman <[EMAIL PROTECTED]> wrote: -Original Message- From: Dmitry Teslenko [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2008 6:57 AM To: pgsql-general@postgresql.org Subject: Strange query plan

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 17:55, Igor Neyman <[EMAIL PROTECTED]> wrote: > > -Original Message- > From: Dmitry Teslenko [mailto:[EMAIL PROTECTED] > Sent: Thursday, August 14, 2008 6:57 AM > To: pgsql-general@postgresql.org > Subject: Strange query plan > > Hello! > > I have following table: >

Re: [GENERAL] Strange query plan

2008-08-14 Thread Igor Neyman
-Original Message- From: Dmitry Teslenko [mailto:[EMAIL PROTECTED] Sent: Thursday, August 14, 2008 6:57 AM To: pgsql-general@postgresql.org Subject: Strange query plan Hello! I have following table: CREATE TABLE table1 ( field1 INTEGER NOT NULL, field2 INTEGER NOT NULL,

Re: [GENERAL] Strange query plan

2008-08-14 Thread Gauthier, Dave
This may be a long shot... But I had a slow query once on a large table because the query plan was doing a sequential scan, even after analyze. I set "default_statistics_target" to 1000 (in postgres.conf), rebooted and reanalyzed. A much better query plan was developed as a result and the query w

Re: [GENERAL] In-place conversion of type bool

2008-08-14 Thread Alvaro Herrera
Joost Kraaijeveld wrote: > > ALTER TABLE ... ALTER COLUMN TYPE might help you. Use the USING clause > > if you need a non-default data conversion -- in this case it might look > > like USING (col = '1') or some such. > > ALTER TABLE odbcdest ALTER COLUMN odbc_bool TYPE bool > > gives: > > ERRO

Re: [GENERAL] Newbie [CentOS 5.2] service postgresql initdb

2008-08-14 Thread Scott Marlowe
On Thu, Aug 14, 2008 at 4:18 AM, Daneel <[EMAIL PROTECTED]> wrote: > Martin Marques wrote: >> >> Daneel escribió: >>> >>> Daneel wrote: While going through http://wiki.postgresql.org/wiki/Detailed_installation_guides and typing service postgresql start as root I got >>

Re: [GENERAL] Newbie [CentOS 5.2] service postgresql initdb

2008-08-14 Thread Daneel
Scott Marlowe wrote: On Tue, Aug 12, 2008 at 9:25 AM, Daneel <[EMAIL PROTECTED]> wrote: While going through http://wiki.postgresql.org/wiki/Detailed_installation_guides and typing service postgresql start as root I got "/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initializ

Re: [GENERAL] Newbie [CentOS 5.2] service postgresql initdb

2008-08-14 Thread Daneel
Martin Marques wrote: Daneel escribió: Daneel wrote: While going through http://wiki.postgresql.org/wiki/Detailed_installation_guides and typing service postgresql start as root I got "/var/lib/pgsql/data is missing. Use "service postgresql initdb" to initialize the cluster first." When I r

Re: [GENERAL] Newbie [CentOS 5.2] service postgresql initdb

2008-08-14 Thread Daneel
Scott Marlowe wrote: PLEASE DON'T WRITE TO THIS LIST WITH A FAKE EMAIL ADDRESS. It's been discussed before, but it's rude and counterproductive. Just set up a filter / account that drops everything coming in, but don't stick the rest of us with your broken email behaviour I'm sorry, just foll

Re: [GENERAL] pg_restore fails on Windows

2008-08-14 Thread Magnus Hagander
Tom Tom wrote: > Magnus Hagander wrote: >> Tom Tom wrote: Tom Tom wrote: > Hello, > > We have a very strange problem when restoring a database on Windows XP. > The PG version is 8.1.10 > The backup was made with the pg_dump on the same machine. > > pg_restore -F c -

Re: [GENERAL] Strange query plan

2008-08-14 Thread Martin Gainty
the columns referenced in the predicate need to reference columns whichimplement indexes to avert FTSAnyone else?Martin __ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. T

Re: [GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
On Thu, Aug 14, 2008 at 15:30, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > Am Thursday, 14. August 2008 schrieb Dmitry Teslenko: >> SELECT SUM(...) FROM table1 WHERE field3 = 'ABC' AND field1 <> 1 >> GROUP BY field2 >> >> And planner picks up a sequential scan of a table. Why does he? > > P

Re: [GENERAL] Postgres 8.3 is not using indexes

2008-08-14 Thread Gregory Stark
"Clemens Schwaighofer" <[EMAIL PROTECTED]> writes: > Any tips why this is so? They don't appear to contain the same data. If they do have you run analyze recently? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's PostGIS support! -- Sent vi

Re: [GENERAL] Strange query plan

2008-08-14 Thread Peter Eisentraut
Am Thursday, 14. August 2008 schrieb Dmitry Teslenko: > SELECT SUM(...) FROM table1 WHERE field3 = 'ABC' AND field1 <> 1 > GROUP BY field2 > > And planner picks up a sequential scan of a table. Why does he? Presumably because it thinks it is the best plan, and I see no reason to doubt that

Re: [GENERAL] Postgres 8.3 is not using indexes

2008-08-14 Thread Peter Eisentraut
Am Thursday, 14. August 2008 schrieb Clemens Schwaighofer: > Why is Postgres not using the indexes in the 8.3 installation. Might have something to do with the removal of some implicit casts. You should show us your table definitions. -- Sent via pgsql-general mailing list (pgsql-general@postg

[GENERAL] Strange query plan

2008-08-14 Thread Dmitry Teslenko
Hello! I have following table: CREATE TABLE table1 ( field1 INTEGER NOT NULL, field2 INTEGER NOT NULL, field3 CHARACTER(30), ... some more numeric fields) I have also those indexes: CREATE UNIQUE INDEX idx1 ON table1 USING btree (field3, field2, field1) CREATE IN

[GENERAL] Postgres 8.3 is not using indexes

2008-08-14 Thread Clemens Schwaighofer
Hi, i just stumbled on something very strange. I have here a Postgres 8.3 and a Postgres 8.2 installation, as I am in the process of merging. Both are from the debian/testing tree, both have the same configuration file. In my DB where I found out this trouble I have two tables, I do a very simpl

Re: [GENERAL] Design decision advice

2008-08-14 Thread William Temperley
On Thu, Aug 14, 2008 at 2:55 AM, Craig Ringer <[EMAIL PROTECTED]> wrote: > William Temperley wrote: >> A. Two databases, one for transaction processing and one for >> modelling. At arbitrary intervals (days/weeks/months) all "good" data >> will be moved to the modelling database. >> B. One databas

[GENERAL] Re: pg_restore fails on Windows

2008-08-14 Thread Tom Tom
Magnus Hagander wrote: > Tom Tom wrote: > >> Tom Tom wrote: > >>> Hello, > >>> > >>> We have a very strange problem when restoring a database on Windows XP. > >>> The PG version is 8.1.10 > >>> The backup was made with the pg_dump on the same machine. > >>> > >>> pg_restore -F c -h localhost -p 543

Re: [GENERAL] Referential integrity vulnerability in 8.3.3

2008-08-14 Thread Joris Dobbelsteen
Richard Huxton wrote, On 15-Jul-2008 15:19: Sergey Konoplev wrote: Yes it is. But it the way to break integrity cos rows from table2 still refer to deleted rows from table1. So it conflicts with ideology isn't it? Yes, but I'm not sure you could have a sensible behaviour-modifying BEFORE tri

[GENERAL] PostgreSQL arrays and DBD

2008-08-14 Thread Александр Чешев
Hello. I create a table: CREATE TABLE groups ( group_id serial PRIMARY KEY, name varchar(64) UNIQUE NOT NULL, guests integer[] DEFAULT '{}' ) I add a new record to the table: INSERT INTO groups (name) VALUES ('My friends'); Now the table contains 1 record: | group_id |name| gues

Re: [GENERAL] cannot use result of (insert .. returning)

2008-08-14 Thread Pavel Stehule
Hello you can wrap INSERT STATEMENT into function. Than you can do anything with result; create table f(a timestamp); postgres=# select * from (insert into f values(current_timestamp) returning *) x where x.a > now(); ERROR: syntax error at or near "into" LINE 1: select * from (insert into f va

Re: [GENERAL] cannot use result of (insert .. returning)

2008-08-14 Thread Dale Harris
I've found my solution as in the help file under "RETURNING INTO". It would be nice if this was referenced on the INSERT documentation. Dale From: [EMAIL PROTECTED] Sent: Thursday, 14 August 2008 15:32 To: pgsql-general@postgresql.org Subject: [GENERAL] cannot use result of (insert .. ret