Re: [SQL] Howto insert or update ?

2010-11-22 Thread tv
Currently I have a trigger function that should store a value in tableX whenever a certain column in tableY gets changed. I do it with: a) delete from tableX where key = ( A, B ) ( regardless if there is one ) b) insert into tableX This seems not very efficient though it works. Is

Re: [SQL] Query Performance

2009-12-07 Thread tv
Yes, the problem is the nested loop scan - it's scanning users 609070 times, which is awful. Could you provide explain plan that executed fast? Was it executed with the same parameter values or did the parameters change (maybe it's slow for some parameters values only)? Have you tried to rewrite

Re: [SQL] Subsorting GROUP BY data

2008-11-10 Thread tv
What about replacing the table by SELECT * FROM my_table ORDER BY num i.e. something like SELECT cat, LAST(id), LAST(num) FROM (SELECT * FROM my_table ORDER BY num) AS foo GROUP_BY cat; Hope it works, just guessing it might help :-) regards Tomas SELECT cat, MAX(num) FROM my_table GROUP_BY

Re: [SQL] SQL tree duplication

2008-01-24 Thread tv
Hi, I have the following kind of sql structure, in 3 levels: --- create table documents ( id serial, name varchar(50), primary key (id) ); create table lines ( id serial, name varchar(50), document_id integer, primary key (id), foreign key

[SQL] storing access rights in a postgres database

2006-10-10 Thread tv
Hi, we are developping a web application in which we need to manage access to several types of objects, the most important objects are 'company', 'projects', 'subproject', 'module' (and several others but that's not important for now). In general these objects constitute a tree, as for example

[SQL] converting varchar to integer

2005-08-16 Thread tv
Hi, I have a varchar column, and I need to 1) check the value in it is an integer 2) get the integer value (as integer) The problem is I can't suppose the're only correct values - ie there can be something like 'xssdkjsd', '230kdd' or even an empty string etc. I've been