[SQL] Query runs very slowly in Postgres, but very fast in other DBMS

2005-04-11 Thread Andrus Moor
Tables: CREATE TABLE dok ( dokumnr NUMERIC(12), CONSTRAINT dok_pkey PRIMARY KEY (dokumnr) ); CREATE TABLE rid ( dokumnr NUMERIC(12) ); CREATE INDEX rid_dokumnr_idx ON rid (dokumnr); Query: SELECT dokumnr FROM rid WHERE dokumnr NOT IN (select dokumnr FROM dok); runs VERY slowly in Po

Re: [SQL] Merging item codes using referential integrity

2005-04-10 Thread Andrus Moor
> Andrus Moor wrote: >> I have item table and a lot of child tables where the items are used. >> I want to merge two item codes into single item in all tables. >> It is not nice to write a lot of separate UPDATE statements for each >> table. >> So I want to util

[SQL] Merging item codes using referential integrity

2005-03-26 Thread Andrus Moor
I have item table and a lot of child tables where the items are used. I want to merge two item codes into single item in all tables. It is not nice to write a lot of separate UPDATE statements for each table. So I want to utilize REFERENCES clause for merging. I tried the following code but got du

[SQL] How to make update statement to work

2005-03-26 Thread Andrus Moor
I want to nullify fields which does not exist in reference table. I tried UPDATE demo.toode SET "liik"=NULL,"grupp"=NULL WHERE ("grupp","liik") NOT IN (SELECT ("grupp", "liik") FROM "artliik") but this causes error: ERROR: operator d

[SQL] select a list of schema names

2005-03-26 Thread Andrus Moor
I want to implement a multi-company database where each schema represents different company. I created a number of schemas in a database. How to select a list of schema names which current user is authorized to access ? I want to get the list of companies to allow user pick the one. ---