Re: [GENERAL] How do I bump a row to the front of sort efficiently

2015-02-02 Thread hubert depesz lubaczewski
On Mon, Feb 02, 2015 at 05:16:40PM +1100, Sam Saffron wrote: > Even this is fast, and logically equiv as id is primary key unique > select * from topic > where id = 1000 > union all > select * from ( > select * from topics > where id <> 1000 > order by bumped_at desc > limit 30 > ) as x > l

[GENERAL] Can I habe multi table indices?

2015-02-02 Thread Andreas
Hi, can I habe multi table indices to ensure that certain IDs can only appear in on relation? Like table_0(id int), table_1(id int), table_2(id int) rel_1_to_0( id_1 int, id_0 int ) rel_2_to_0( id_2 int, id_0 int ) An id of table_0 should only exist either in rel_1_to_0 OR rel_2_to_0. How

Re: [GENERAL] Problem with REFERENCES on INHERITS

2015-02-02 Thread William Gordon Rutherdale
On 02/02/15 12:11 AM, David G Johnston wrote: > William Gordon Rutherdale wrote >> My problem: could someone please explain the semantics and why this >> behaviour makes sense -- or is it a design error or bug? > I didn't read your post in depth but I suspect you have not read and > understood th

Re: [GENERAL] How do I bump a row to the front of sort efficiently

2015-02-02 Thread Tim Clarke
On 02/02/15 08:40, hubert depesz lubaczewski wrote: > On Mon, Feb 02, 2015 at 05:16:40PM +1100, Sam Saffron wrote: >> Even this is fast, and logically equiv as id is primary key unique >> select * from topic >> where id = 1000 >> union all >> select * from ( >> select * from topics >> where id

Re: [GENERAL] Can I habe multi table indices?

2015-02-02 Thread Albe Laurenz
Andreas wrote: > can I habe multi table indices to ensure that certain IDs can only > appear in on relation? > > Like > > table_0(id int), table_1(id int), table_2(id int) > rel_1_to_0( id_1 int, id_0 int ) > rel_2_to_0( id_2 int, id_0 int ) > > An id of table_0 should only exist either in re

Re: [GENERAL] BDR Error restarted

2015-02-02 Thread theftp
Hi all, I have a similar problem. OS Red Hat Enterprise Linux Server release 6.6. Postgresql packets were installed from repository as described in https://wiki.postgresql.org/wiki/BDR_Packages postgresql-bdr94-bdr-0.8.0beta1-1_2ndQuadrant.el6.x86_64 postgresql-bdr94-contrib-9.4.0_bdr1-1_2ndQua

Re: [GENERAL] Problem with REFERENCES on INHERITS

2015-02-02 Thread Tom Lane
William Gordon Rutherdale writes: > So this statement: > INSERT INTO banana_stash(primate_id, qty) VALUES (1, 17); > Resulted in this error: > ERROR: insert or update on table "banana_stash" violates foreign key > constraint "banana_stash_primate_id_fkey" > DETAIL: Key (primate_id)=(1) is not pr

Re: [GENERAL] cannot start 9.3 after system crash

2015-02-02 Thread Merlin Moncure
On Tue, Jan 27, 2015 at 5:42 AM, Andreas Laggner wrote: > Hi list, > > the system HDD of a server running postgresql 9.3 died (sudden electronical > death) during a pg_dump. The database is located on a hardware raid system > (another HDD). I installed a new ubuntu 14.04 with postgresql 9.3 postgi

Re: [GENERAL] Problem with REFERENCES on INHERITS

2015-02-02 Thread William Gordon Rutherdale
On 02/02/15 10:11 AM, Tom Lane wrote: > If you did "select * from only primate" you would see that there is no > such row in the parent table, which is what the foreign key is being > enforced against. Thanks. That does a lot to clarify it. -Will -- Sent via pgsql-general mailing list (pgsq

Re: [GENERAL] Catalog Bloat

2015-02-02 Thread Jim Nasby
On 1/30/15 11:22 AM, Bill Moran wrote: >Any suggestions on eliminating? Not sure if tools like pg_reorg are >appropriate (or effective) or even vacuum full (yikes). >I'd prefer not to take a complete outage - but I would if this bloat is >really an issue. I don't know the parameters of the syst

[GENERAL] Question on session_replication_role

2015-02-02 Thread Anand Kumar, Karthik
Our set up: * Db version: postgres 9.3.4 * OS: CentOS 5.6 * kernel Version - Linux 2.6.18-238.19.1.el5 #1 SMP Fri Jul 15 07:31:24 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux * memory - 256 GB * We have slony replicating to this DB from the primary server *

Re: [GENERAL] array in a store procedure in C

2015-02-02 Thread Jim Nasby
On 1/29/15 10:53 PM, Juan Pablo L wrote: i will look there ... i have been looking in a lot of source files and can not find anything that helps but i will look in those specific files. Thanks a lot. You might find this shell script useful; it's meant to make it easy to grep the entire codebas

Re: [GENERAL] Question on session_replication_role

2015-02-02 Thread Jim Nasby
On 2/2/15 8:07 PM, Anand Kumar, Karthik wrote: 2)When we run the selects on each table separately, the query runs really fast. The moment we introduce the join (AND EXISTS), the sql takes over 30 seconds. 3)The explain plan of this query shows that Primary key on reg_email_subscriptions and uniq

Re: [GENERAL] oracle to postgres

2015-02-02 Thread Jim Nasby
On 1/29/15 3:02 PM, Adrian Klaver wrote: On 01/29/2015 03:16 AM, Ramesh T wrote: hello, can any one help me to convert oracle to postgres script..? following code .. BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONTAINER'; EXCEPTION WHEN OTHERS THEN IF SQLCODE != -942 THEN RAISE;

Re: [GENERAL] oracle to postgres

2015-02-02 Thread Jim Nasby
On 2/2/15 9:13 PM, Jim Nasby wrote: On 1/29/15 3:02 PM, Adrian Klaver wrote: On 01/29/2015 03:16 AM, Ramesh T wrote: hello, can any one help me to convert oracle to postgres script..? following code .. BEGIN EXECUTE IMMEDIATE 'DROP TABLE CONTAINER'; EXCEPTION WHEN OTHERS THEN IF

Re: [GENERAL] Versioning Schema SQL ideas needed

2015-02-02 Thread Jim Nasby
On 1/26/15 4:38 PM, Tim Smith wrote: create table templates( template_id int not null primary key, template_groupid int not null, template_version int not null template_text text not null); My thinking on the above is : - template_id is a unique ID for that version - template_gro

Re: [GENERAL] Synchronous archiving

2015-02-02 Thread Jim Nasby
On 1/27/15 1:51 AM, Laurence Rowe wrote: I have a relatively small database with not many writes. However, I'm keen to ensure that those writes I receive are not lost. Archiving gets me most of the way there, but it is asynchronous. Is there any way to archive individual WAL records without runni

Re: [GENERAL] partial "on-delete set null" constraint

2015-02-02 Thread Jim Nasby
On 1/3/15 2:49 AM, Rafal Pietrak wrote: -test schema--- CREATE TABLE maildomains (domain text primary key, profile text not null); CREATE TABLE mailusers (username text , domain text references maildomains(domain) on update cascade, primary key (username, domain)); C

Re: [GENERAL] Synchronous archiving

2015-02-02 Thread Michael Paquier
On Tue, Feb 3, 2015 at 12:30 PM, Jim Nasby wrote: > On 1/27/15 1:51 AM, Laurence Rowe wrote: >> >> I have a relatively small database with not many writes. However, I'm >> keen to ensure that those writes I receive are not lost. Archiving gets >> me most of the way there, but it is asynchronous. I

Re: [GENERAL] hash function in Postgres

2015-02-02 Thread Jim Nasby
On 1/24/15 9:03 AM, Adrian Klaver wrote: On 01/23/2015 10:42 PM, Ravi Kiran wrote: hi, I want to know what kind of hash function postgresql uses while joining. I was debugging through gdb, I found out that it is not using bob jenkins hash function but a different hash function *hash_uint32() a

Re: [GENERAL] array in a store procedure in C

2015-02-02 Thread Juan Pablo L
Thanks. On Feb 2, 2015 8:58 PM, "Jim Nasby" wrote: > On 1/29/15 10:53 PM, Juan Pablo L wrote: > >> i will look there ... i have been looking in a lot of source files and >> can not find anything that helps but i will look in those specific >> files. Thanks a lot. >> > > You might find this shell