Re: [GENERAL] request help forming query

2008-02-25 Thread danmcb
yes, this could get called on quite large tables (maybe not billions ...). The second solution looks useful - I'll try it on some test data. thanks both of you. ---(end of broadcast)--- TIP 2: Don't 'kill -9' the postmaster

[GENERAL] request help forming query

2008-02-24 Thread danmcb
Hi !'ve been wondering how to formulate a query to get a set of objects out of a database, and am a bit stuck. I hope that someone here might be able to help. This is what the db looks like: Table TYPES id int primary key, description text Table GROUPS id int primary key description text Table

Re: [GENERAL] how to implement unusual constraint

2007-06-24 Thread danmcb
"So frequently the best advice for someone who's thinking of doing something like this is "redesign your schema so you don't need to". " I've thought about that. The obvious way to do it would be to split into two tables, one for the originals, one for the translations (the objects are actually ph

[GENERAL] how to implement unusual constraint

2007-06-24 Thread danmcb
Say I have a table, say my_table, that is self-referencing. It looks like this : id integer pk, orig_id integer references my_table(id), . . . Now this set of rows would be legal id/orig_id 1 /1 2/1 3/1 4/4 5/4 but this not: id/orig_id 1 /1 2/1 3/1 4/1 5/4 in other words: the row pointed to

Re: [GENERAL] finding items with 0 rels for a 0 to many relationship

2007-06-24 Thread danmcb
thanks both for this. I haven't got around to writing this part of the code yet, but will do soon. I appreciate the pointers. On 21 Jun, 19:13, [EMAIL PROTECTED] (Michael Glaesemann) wrote: > On Jun 21, 2007, at 11:57 , Josh Tolley wrote: > > > > > On 6/21/07, danmcb &l

[GENERAL] finding items with 0 rels for a 0 to many relationship

2007-06-21 Thread danmcb
Hi I have two tables, say A and B, that have a many-to-many relationship, implemented in the usual way with a join table A_B. How can I economically find all the rows in table A whose id's are not in A_B at all (i.e. they have zero instances of B associated)? Thanks Daniel --

Re: [GENERAL] optimisation for a table with frequently used query

2007-05-29 Thread danmcb
I just did some checks on two seperate indexes c.f. one combined one. I saw almost no difference between making select statements. Haven't tried what happens with many updates - makes sense that more indexes will slow that down though. again thanks - bit of a noob question I know, but it's good t

Re: [GENERAL] optimisation for a table with frequently used query

2007-05-29 Thread danmcb
Thanks! ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMAIL PROTECTED] so that your message can get through to the mailing list cleanly

[GENERAL] optimisation for a table with frequently used query

2007-05-28 Thread danmcb
Hi, I have a table that looks like this: CREATE TABLE my_table { id SERIAL PRIMARY KEY, id_1 INTEGER REFERENCES tab1(id), id_2 INTEGER REFERENCES tab2(id), . . . }; I will often be running queries that look like SELECT * from my_table where id_1 = x and id_2 = y; Neither id_1 or id