Re: [SQL] Select clause in JOIN statement

2013-06-14 Thread Andreas Joseph Krogh
tomer.status = b.status_id WHERE b.status_id > 0 But you can JOIN on SELECTs selecting arbitrary stuff.   -- Andreas Joseph Krogh       mob: +47 909 56 963 Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no Public key: http://home.officenet.no/~andreak/public_key.asc  

Re: [SQL] Change in 9.1?

2011-11-22 Thread Andreas Joseph Krogh
r to give you an answer if you provided a query which worked before which now, in 9.1, gives you trouble. -- Andreas Joseph Krogh - mob: +47 909 56 963 Senior Software Developer / CTO - OfficeNet AS - http://www.officenet.no Public key: http://home.officenet.no/~andreak/public_key.asc  

Re: [SQL] large xml database

2010-10-30 Thread Andreas Joseph Krogh
ndElement(String name) events to insert the element's content into your db. - -- Andreas Joseph Krogh Senior Software Developer / CTO Public key: http://home.officenet.no/~andreak/public_key.asc - +-+ OfficeNet AS

Re: [SQL] workaround for missing ROWNUM feature with the help of GUC variables

2010-08-04 Thread Andreas Joseph Krogh
.html Example: select username, row_number() over() from my_user_table; username | row_number -+ admin | 1 everyone| 2 -- Andreas Joseph Krogh Senior Software Developer

Re: [SQL] Order of "WITH RECURSIVE" output

2009-07-06 Thread Andreas Joseph Krogh
On Tuesday 07 July 2009 03:55:35 am Tom Lane wrote: > Andreas Joseph Krogh writes: > > If I omit "ORDER BY", is the output *guaranteed* (according to some > > standard) to be ordered > > No. It's not necessary to read any other details to answer that ... >

[SQL] Order of "WITH RECURSIVE" output

2009-07-06 Thread Andreas Joseph Krogh
ible and hence avoid unnecessary sorting. -- Andreas Joseph Krogh Senior Software Developer / CTO +-+ OfficeNet AS| The most difficult thing in the world is to | Rosenholmveien 25 | know how to do a thing and to

Re: [SQL] Re: SQL to Check whether "AN HOUR PERIOD" is between start and end timestamps

2009-04-16 Thread Andreas Joseph Krogh
QUERY PLAN -------- Seq Scan on onp_crm_activity_log (cost=0.00..319.29 rows=2968 width=4) (actual time=14.542..15.794 rows=83 loops

Re: [SQL] store pdf files

2008-12-09 Thread Andreas Joseph Krogh
ou'll loose transactional safety the DB provides. That reason alone is good enough to justify storing the files in a BLOB (BYTEA in PG). The length(BYTEA)-function in PG can be used to retrieve its length. It is IMMUTABLE and "constant time", which means you can apply a functio

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Andreas Joseph Krogh
On Friday 07 November 2008 21:09:33 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > AFAICS this lists all tables which have a column named '?', which is not > > what I'm after. I'm after listing all columns referencing a certain col

Re: Res: [SQL] Finding all tables that have foreign keys referencing a table

2008-11-07 Thread Andreas Joseph Krogh
out how to safely get all columns which reference test1.id? -hackers; Any hints? BTW: andreak=# select version(); version ----------- PostgreSQL 8.3.3 on i486-pc-linux-gnu, compiled by GCC cc (GCC) 4.2.3 (Ubuntu 4.2.3-2ubuntu7) -- Andreas Joseph Krogh <[EMA

[SQL] Finding all tables that have foreign keys referencing a table

2008-11-06 Thread Andreas Joseph Krogh
. I'm trying to make a function which finds all my old "$1" constraints and replaces those names with proper names (_fkey). So - anybody who knows a good solution for how to find all tables with constraint-names that have foreign keys referencing a table's particluar colum? --

Re: [SQL] simple SQL query

2008-10-29 Thread Andreas Joseph Krogh
E col NOT IN ()" doesn't match NULL-values for "col", so these will both return "false" for NULL-value of "col": WHERE col NOT IN (2,3) WHERE col = 2 The reason is that NULL is "unknown", so testing against it a

Re: [SQL] simple SQL query

2008-10-29 Thread Andreas Joseph Krogh
have NULLs in some of the rows so your "NOT IN" doesn't work. I suggest you rewrite to something like: ... WHERE (securitytypekey IS NOT NULL OR securitytypekey NOT IN (5,27))... > Question: does a UNIQUE constraint create an index? Yes. > Maybe your fresh eyes will see som

Re: [SQL] Verify Execute

2008-06-24 Thread Andreas Joseph Krogh
. Note that usually INSERT, UPDATE and DELETE return an integer > 0, indicating affected rows, but not always. There might be 0 affected rows, which is not nessesarily an error. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +--

Re: [SQL] Slow Query problem

2008-01-29 Thread Andreas Joseph Krogh
need? Your tables, views and index definitions. > Any other advise? You haven't provided any information on how your tables/views look like and what indexes you have defined. A rule of thumb is to define an index for each column you join on. -- Andreas Joseph Krogh <[EMAIL P

Re: [SQL] Slow Query problem

2008-01-28 Thread Andreas Joseph Krogh
let me have a link. It is very hard to help without you providing the schema for the tables/views involved. It sounds like you don't have any indexes if you experience performance-problems on queries like "select * from view_transaction where member_id = 999 and receipt_no is null&

[SQL] ALTER TABLE DROP CONSTRAINT IF EXISTS ?

2008-01-23 Thread Andreas Joseph Krogh
Does PG have any way of doing $subject without writing a plpgsql-function which does it by querying the catalog manually? I'm looking for an equivalent of "DROP TABLE IF EXISTS " -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Softwar

[SQL] Having elements of an int[]-array reference other tables

2008-01-21 Thread Andreas Joseph Krogh
would be nice if one could have elements in test.id_array to reference elements in master.my_id, with all the benefits of ON DELETE | UPDATE etc. I know I can accomplish this with triggers, but if there exists something built-in I'd like to know. -- Andreas Joseph Krogh <[EMAIL P

[SQL] PG trouble with index-usage in sort

2007-11-26 Thread Andreas Joseph Krogh
time=0.031..424.250 rows=200828 loops=1) Total runtime: 2574.113 ms (9 rows) Can anybody point out to me why PG doesn't perform better on the last query? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +--

[SQL] Loading 8.2 data into 8.1

2007-11-20 Thread Andreas Joseph Krogh
Hi. Is it considered "safe" to use 8.1's pg_dump to dump an 8.2-db and load it into 8.1? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +-+ OfficeNet AS| The mo

[SQL] Problem with UNION-queries

2007-11-12 Thread Andreas Joseph Krogh
y, t.value from test1 t where t.key = 'A' UNION select t.username, t.key, t.value from test1 t where t.key = 'B' UNION select t.username, t.key, t.value from test1 t where t.value NOT IN ( select value from ( select t.username, t.key, t.value from test1 t where t.key = 

Re: [SQL] Returning the total number of rows as a separate column when using limit

2007-11-05 Thread Andreas Joseph Krogh
On Monday 05 November 2007 16:27:03 Gregory Stark wrote: > > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > >> On Monday 05 November 2007 15:18:22 Tom Lane wrote: > >>> That's only an estimate. Since the query doesn't get executed to > >>&

Re: [SQL] Returning the total number of rows as a separate column when using limit

2007-11-05 Thread Andreas Joseph Krogh
On Monday 05 November 2007 15:18:22 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > AFAICS the information about the *total* number of rows is in the > > "result" somehow. When I execute a "limit 1" query with EXPLAIN ANALYZE, >

[SQL] Returning the total number of rows as a separate column when using limit

2007-11-04 Thread Andreas Joseph Krogh
count(*)"-query to count the totals, which is exactly what I'm trying to avoid. Oracle has a special rownum and over() which can be used to accomplish this: SELECT tmp.*, max(rownum) over() as total_count FROM (subquery) tmp Does PG have any equivalent way? -- Andreas Josep

[SQL] Returning the total number of rows as a separate column when using limit

2007-10-31 Thread Andreas Joseph Krogh
m and over() which can be used to accomplish this: SELECT tmp.*, max(rownum) over() as total_count FROM (subquery) tmp Does PG have any equivalent way? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +-

Re: [SQL] OT: array_accum equivalent in Oracle

2007-10-12 Thread Andreas Joseph Krogh
On Friday 12 October 2007 17:02:23 Jonah H. Harris wrote: > On 10/12/07, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > Anybody knows if Oracle has an equivalent of PG's array_accum or > > ARRAY(subselect) construct? > > Something like this: > > CR

[SQL] OT: array_accum equivalent in Oracle

2007-10-12 Thread Andreas Joseph Krogh
n where to look in Oracle-docs are welcome. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +-+ OfficeNet AS| The most difficult thing in the world is to | Karenslyst Allé 11

Re: [SQL] Format intervall as hours/minutes etc

2007-09-16 Thread Andreas Joseph Krogh
On Sunday 16 September 2007 17:41:56 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > On Sunday 16 September 2007 13:14:27 Andreas Kretschmer wrote: > >> You can use extract(epoch, from ...) like this: > >> > >> test=*# select extrac

Re: [SQL] Format intervall as hours/minutes etc

2007-09-16 Thread Andreas Joseph Krogh
On Sunday 16 September 2007 13:14:27 Andreas Kretschmer wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> schrieb: > > Hi all. Any hint on how to format this interval as number of hour/seconds > > etc? select age('2007-09-22 17:00'::timestamp, '20

[SQL] Format intervall as hours/minutes etc

2007-09-16 Thread Andreas Joseph Krogh
Hi all. Any hint on how to format this interval as number of hour/seconds etc? select age('2007-09-22 17:00'::timestamp, '2000-02-20 18:00'::timestamp); age --- 7 years 7 mons 1 day 23:00:00 -- Andreas Joseph Krogh <[EMAIL PROT

Re: [SQL] Returning array of IDs as a sub-query with group-by

2007-08-25 Thread Andreas Joseph Krogh
On Saturday 25 August 2007 23:02:19 Ragnar wrote: > On lau, 2007-08-25 at 17:55 +0200, Andreas Joseph Krogh wrote: > > On Saturday 25 August 2007 17:10:57 Andreas Joseph Krogh wrote: > > [snip] > > > > count | item

Re: [SQL] Returning array of IDs as a sub-query with group-by

2007-08-25 Thread Andreas Joseph Krogh
On Saturday 25 August 2007 17:10:57 Andreas Joseph Krogh wrote: > Hi all. > I have the following schema: > > create table item( > id serial primary key > ); > > > create table item_log( > id serial primary key, > item_id integer not null references i

[SQL] Returning array of IDs as a sub-query with group-by

2007-08-25 Thread Andreas Joseph Krogh
array FROM item i, item_log il WHERE i.id = il.item_id GROUP BY il.price, i.id; ERROR: subquery uses ungrouped column "il.id" from outer query Any hints? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Softwar

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Saturday 11 August 2007 21:55:49 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > On Friday 10 August 2007 23:30:14 Tom Lane wrote: > >> Reverse-sorted index columns are possible but not well supported in > >> existing PG releases (you need

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Saturday 11 August 2007 21:05:22 hubert depesz lubaczewski wrote: > On Fri, Aug 10, 2007 at 04:53:12PM +0200, Andreas Joseph Krogh wrote: > > I have the following test-case: > > > > CREATE TABLE test( > > name varchar PRIMARY KEY, > > value varchar NOT NUL

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-11 Thread Andreas Joseph Krogh
On Friday 10 August 2007 23:30:14 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Is there a way I can have multiple columns in the ORDER BY clause, each > > with different ASC/DESC-order and still use an index to speed up sorting? > > A btree inde

[SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-10 Thread Andreas Joseph Krogh
ent sort-order) use an index? Preferrably without having to create 2^N indexes. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +-+ OfficeNet AS| The most difficult thing in t

Re: [SQL] PG won't use index on ORDER BY

2007-08-09 Thread Andreas Joseph Krogh
On Thursday 09 August 2007 22:38:46 Andreas Joseph Krogh wrote: > On Thursday 09 August 2007 22:00:54 Gregory Stark wrote: > > "Andreas Joseph Krogh" <[EMAIL PROTECTED]> writes: > > > I create an index: > > > CREATE INDEX person_lowerfullname_id

Re: [SQL] PG won't use index on ORDER BY

2007-08-09 Thread Andreas Joseph Krogh
On Thursday 09 August 2007 22:57:35 Rodrigo De León wrote: > On 8/9/07, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > Ooops, just fugured that out. But - it still doesn't use the index if I > > remove the "varchar_pattern_ops". > > Huh? > > C

Re: [SQL] PG won't use index on ORDER BY

2007-08-09 Thread Andreas Joseph Krogh
On Thursday 09 August 2007 22:00:54 Gregory Stark wrote: > "Andreas Joseph Krogh" <[EMAIL PROTECTED]> writes: > > I create an index: > > CREATE INDEX person_lowerfullname_idx ON > > person((lower(COALESCE(firstname, '')) || lower(COALESCE(lastname,

[SQL] PG won't use index on ORDER BY

2007-08-09 Thread Andreas Joseph Krogh
t; to ensure that it will use an index if one appropriate exists -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +-+ OfficeNet AS| The most difficult thing in the world is to | Karensly

Re: [SQL] Alternative to INTERSECT

2007-07-31 Thread Andreas Joseph Krogh
On Tuesday 31 July 2007 18:52:22 Josh Trutwin wrote: > On Tue, 31 Jul 2007 17:30:51 + > > Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > Hi all. I have the following schema: > > > > CREATE TABLE test ( > > id integer NOT NULL, > > fi

[SQL] Alternative to INTERSECT

2007-07-31 Thread Andreas Joseph Krogh
7;andrea%' INTERSECT SELECT t.id FROM test t WHERE t.field = 'firstname' AND t.value LIKE 'jose%' INTERSECT SELECT t.id FROM test t WHERE t.field = 'lastname' AND t.value LIKE 'kro%'; id 1 (1 row) Is there a way to make this more efficient

[SQL] Table-name as parameter to plpgsql

2007-07-30 Thread Andreas Joseph Krogh
INTO $1 (some_field) VALUES('some_value') Any hints on how to use function-parameters as table-names like I'm trying to above? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager +

Re: [SQL] Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?

2007-06-28 Thread Andreas Joseph Krogh
On Thursday 28 June 2007 17:54:59 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Anybody knows if queries of type "LIKE '%234%'" ever will be able to use > > indexes, and if someone is working on it? > > Perhaps you are looki

Re: [SQL] Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?

2007-06-28 Thread Andreas Joseph Krogh
On Thursday 28 June 2007 17:20:56 Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Anybody knows if the following query will use an index-scan in PG-8.3? > > SELECT name FROM person WHERE name LIKE 'and%'; > > I know this works in "C

[SQL] Is index usage in LIKE-queries with UTF-8 implemented in PG-8.3 ?

2007-06-28 Thread Andreas Joseph Krogh
Hi all. Anybody knows if the following query will use an index-scan in PG-8.3? SELECT name FROM person WHERE name LIKE 'and%'; I know this works in "C"-locale, but I need it with UTF-8, probably the rest of the world soon too... -- Andreas Joseph Krogh <[EMAIL PROT

Re: [SQL] Conditional NOT NULL constraint

2007-02-28 Thread Andreas Joseph Krogh
On Wednesday 28 February 2007, Richard Huxton wrote: > Andreas Joseph Krogh wrote: > > Hi all! > > Is there a simple way to add a "NOT NULL constraint" to a column without > > using a trigger if another column is not null? > > Something like this: > &g

[SQL] Conditional NOT NULL constraint

2007-02-28 Thread Andreas Joseph Krogh
a way to do this with an index. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager gpg public_key: http://dev.officenet.no/~andreak/public_key.asc +-+ OfficeNet AS| The most dif

[SQL] lower() not working correctly...?

2006-09-15 Thread Andreas Joseph Krogh
I have the following query: select lower(firstname) || ' ' || lower(lastname) from person firstname and lastname are VARCHAR lower() returns NULL when firstname OR lastname is NULL, is this correct? This is 8.2devel from 24.08.2006. -- Andreas Joseph Krogh <[EMAIL PROTECTED]>

Re: [SQL] Alternative to Select in table check constraint

2006-07-07 Thread Andreas Joseph Krogh
constraint is to allow only one active badge > status at a time. > > But now that I think about it, using the authors suggestion (if it actually > worked), how would would it be possible to change the active status from > one badge to another? First set status='I' on the one that

Re: [SQL] Constraint question

2006-05-19 Thread Andreas Joseph Krogh
On Thursday 18 May 2006 18:38, Markus Schaber wrote: > Hi, Andreas, > > Andreas Joseph Krogh wrote: > > create table onp_crm_businessfield_company( > > businessfield_id integer not null references onp_crm_businessfield(id), > > company_id integer not null ref

[SQL] Constraint question

2006-05-18 Thread Andreas Joseph Krogh
"is_preffered" so that it's only allowed to be set once pr. businessfield_id pr. company so that only one businessfield can be preferred for a company. Does anyone have an idea how to enforce this? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager

Re: [SQL] Problem with query on history table

2006-03-01 Thread Andreas Joseph Krogh
new row (all within one transaction). > > There are other ways to do it, but they'll probably be much slower. I > don't think they require a lot of CASE statements though. > > Show us what you were planning on doing and maybe I'll have more ideas. > > On Mon, Feb 27

[SQL] Problem with query on history table

2006-02-26 Thread Andreas Joseph Krogh
urr.modified as curr_modified, hist.modified as hist_modified, coalesce(hist.etc, curr.etc) as etc FROM curr LEFT OUTER JOIN hist ON(curr.id = hist.curr_id) WHERE ... I'm really stuck here. It seems to me that I need a lot of CASE...WHEN...ELSE.. statements in the

Re: [SQL] Problems with distinct

2006-02-13 Thread Andreas Joseph Krogh
On Monday 13 February 2006 20:22, Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > Any idea why this works: > > SELECT distinct(g.groupname), g.id, g.p_id FROM onp_group g, onp_group g2 > > WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM o

[SQL] Problems with distinct

2006-02-13 Thread Andreas Joseph Krogh
onp_group g, onp_group g2 WHERE g.id IN(SELECT g2.id UNION SELECT group_id FROM onp_group_children WHERE child_id = g2.id) AND g2.id IN(1,2,109,105, 112); The *only* difference is that the distinct-clause changed place... -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Dev

Re: [SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
On Sunday 04 September 2005 20:08, Andreas Joseph Krogh wrote: > Replying to my self... Again... I managed to "reduse" my query to the following: SELECT gr.groupname FROM onp_group gr, onp_user u WHERE gr.id IN ( SELECT g.id FROM onp_group g, onp_user_group ug WHER

Re: [SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
ERE gc.group_id = g.id AND g.groupname = ug.groupname AND ug.username = 'andreak'; But I would very much appreciate if someone manages to rewrite this query so that it doesn't specify ug.username='anderak' twice. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Sof

[SQL] Help with UNION query

2005-09-04 Thread Andreas Joseph Krogh
N DELETE CASCADE ON UPDATE CASCADE, primary key(groupname, username) ); -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager gpg public_key: http://dev.officenet.no/~andreak/public_key.asc +-+ Off

Re: [SQL] echo/printf function in plpgsql

2005-07-20 Thread Andreas Joseph Krogh
On Wednesday 20 July 2005 01:39, John DeSoi wrote: > On Jul 19, 2005, at 11:58 AM, Andreas Joseph Krogh wrote: > > I see. Can I make the ouput somehow less verbose? It spits out a > > lot of noise > > for each "NOTICE": > > If you just want to output som

Re: [SQL] echo/printf function in plpgsql

2005-07-19 Thread Andreas Joseph Krogh
On Tuesday 19 July 2005 22:09, Tony Wasson wrote: > On 7/19/05, Andreas Joseph Krogh <[EMAIL PROTECTED]> wrote: > > On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > > > Andreas Joseph Krogh wrote: > > > > Hi all! > > > > > > > > Is

Re: [SQL] echo/printf function in plpgsql

2005-07-19 Thread Andreas Joseph Krogh
On Tuesday 19 July 2005 17:18, Richard Huxton wrote: > Andreas Joseph Krogh wrote: > > Hi all! > > > > Is there a way of echo'ing a string(like "raise notice 'this is id%', > > id") from plpgsql? I want to echo/print it to STDOUT 'c

[SQL] echo/printf function in plpgsql

2005-07-19 Thread Andreas Joseph Krogh
Hi all! Is there a way of echo'ing a string(like "raise notice 'this is id%', id") from plpgsql? I want to echo/print it to STDOUT 'cause the notice-mechanism produces too much noise IMH. -- Andreas ---(end of broadcast)--- TIP 2: Don't 'kill -9'

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-15 Thread Andreas Joseph Krogh
On Friday 15 April 2005 18:34, Markus Schaber wrote: > Hi, Andreas, > > Andreas Joseph Krogh schrieb: > >>Could you try the latest postgresql-8.0-311.jdbcX.jar? The current > >>versions should solve the idle in transaction problem, the previous ones > >>ten

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-15 Thread Andreas Joseph Krogh
On Friday 15 April 2005 18:22, Markus Schaber wrote: > Hi, Andreas, > > Andreas Joseph Krogh schrieb: > >>>So, what you're suggesting is that a restart of the webapp should make > >>>vacuum able to delete those dead rows? > >> > >>Yes, but t

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-14 Thread Andreas Joseph Krogh
On Thursday 14 April 2005 22:44, Andrew Sullivan wrote: > On Thu, Apr 14, 2005 at 09:57:03PM +0200, Andreas Joseph Krogh wrote: > > Is it safe to issue a "kill -2 ", will the > > connection-pool reconnect? > > The kill -2 will definitely work to shut the connectio

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-14 Thread Andreas Joseph Krogh
at's probably off topic for > this list.) I don't see this behaviour under 8.0.0, and it's presumably fixed: http://archives.postgresql.org/pgsql-jdbc/2004-06/msg00018.php Is it safe to issue a "kill -2 ", will the connection-pool reconnect? -- Andreas Joseph

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-14 Thread Andreas Joseph Krogh
On Thursday 14 April 2005 19:33, Andrew Sullivan wrote: > On Thu, Apr 14, 2005 at 07:21:38PM +0200, Andreas Joseph Krogh wrote: > > So, what you're suggesting is that a restart of the webapp should make > > vacuum able to delete those dead rows? > > Yes, but that'll

Re: [SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-14 Thread Andreas Joseph Krogh
On Thursday 14 April 2005 19:12, Richard Huxton wrote: > Andreas Joseph Krogh wrote: > > Hi everybody, I have table which inly has 298 rows in it, but EXPLAIN > > ANALYZE shows that PG thinks it has as much as 160057 rows AFAICT from > > the EXPLAIN-output. > > >

[SQL] row-attribute in EXPLAIN-output doesn't match count(*)

2005-04-14 Thread Andreas Joseph Krogh
s (3 rows) nbeweb=> select count(*) from onp_web_index; count --- 298 (1 row) Is this normal, shall I just overlook the "rows=160057" output from EXPLAIN, or is something wrong? What does the line "DETAIL: 15

Re: [SQL] Very low performance on table with only 298 rows

2005-04-14 Thread Andreas Joseph Krogh
On Thursday 14 April 2005 13:28, Richard Huxton wrote: > Andreas Joseph Krogh wrote: > > nbeweb=> EXPLAIN select count(*) from onp_web_index; > > QUERY PLAN > > - >

[SQL] Very low performance on table with only 298 rows

2005-04-14 Thread Andreas Joseph Krogh
arturl(id) ON DELETE CASCADE Any hints on how I can "fix" this lousy performance? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager gpg public_key: http://dev.officenet.no/~andreak/public_key.asc +---

Re: [SQL] Making NULL entries appear first when ORDER BY ASC

2005-02-16 Thread Andreas Joseph Krogh
r > date. Otherwise change the order in the ORDER BY clause. Thanks! This si, IMO, the cleanest solution as it doesn't involve any COALESCE. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer

[SQL] Making NULL entries appear first when ORDER BY ASC

2005-02-15 Thread Andreas Joseph Krogh
I would like to make all entries where start_time IS NULL apear *before* all the others. Any idea how to achieve this? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> Senior Software Developer / Manager gpg public_key: http://dev.officenet.

Re: [SQL] Problem with LATIN1 characters from Perl-DBI

2004-09-07 Thread Andreas Joseph Krogh
rinting it out to stdout, the 'use encoding' pragma took care of the conversion, but that didn't work for inserting the contents of $plain_text into the database. So I must convert it to latin1 using the from_utf8 su

[SQL] Problem with LATIN1 characters from Perl-DBI

2004-09-07 Thread Andreas Joseph Krogh
Linux system. I first had the problem printing out LATIN1 chars to stdout too, but solved that by using the pragma use encoding 'ISO-8859-1'; I've tried: $dbh->do("set CLIENT_ENCODING TO 'ISO-8859-1'") or die("Couldn't set encoding to ISO-8859-1

Re: [SQL] Inserting data in a table using sub-selects]

2004-03-10 Thread Andreas Joseph Krogh
iption, '') > FROM table1 t1) > WHERE id NOT IN ( > SELECT id > FROM table1); > > With Oracle there is a slick way to do a partial outer join that allowed > you to do this without creating a complete list of table1.id in the last > subquery, but I dunno if

Re: [SQL] Backup of multiple tables

2003-09-22 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Friday 19 September 2003 17:38, Tom Lane wrote: > Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > > I usually backup my database with pg_backup without the -t option. But > > now I need to only backup certain tables(say ta

[SQL] Backup of multiple tables

2003-09-19 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi. I usually backup my database with pg_backup without the -t option. But now I need to only backup certain tables(say tab1 and tab2), is this possible with pg_dump? I've tried with "pg_dump -t tab1 -t tab2" without success. - --

Re: [SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Andreas Joseph Krogh
achment. Can anyone explain to me how to reed the output from ANALYZE. It seems most of the time is spent sorting and grouping. Are there any ways to optimize this? - -- Andreas Joseph Krogh <[EMAIL PROTECTED]> There will always be someone who agrees with you but is

Re: [SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wednesday 15 January 2003 18:55, Achilleus Mantzios wrote: > On Wed, 15 Jan 2003, Andreas Joseph Krogh wrote: > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > On Wednesday 15 January 2003 16:12, you wrote

Re: [SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Wednesday 15 January 2003 16:12, you wrote: > On Wed, 15 Jan 2003, Andreas Joseph Krogh wrote: > > -BEGIN PGP SIGNED MESSAGE- > > Hash: SHA1 > > > > On Wednesday 15 January 2003 11:37, you wrote: > &

Re: [SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Andreas Joseph Krogh
-- But it failes with: ERROR: DefineIndex: index function must be marked isImmutable Now the question is how do I mark an index function isImmutable? - -- Andreas Joseph Krogh <[EMAIL PROTECTED]> There will always be someone wh

[SQL] index on to_char(created, 'YYYY') doesn't work

2003-01-15 Thread Andreas Joseph Krogh
lt of that funtion? Do anyone have an example of such a function? - -- Andreas Joseph Krogh <[EMAIL PROTECTED]> There will always be someone who agrees with you but is, inexplicably, a moron. gpg public_key: http://dev.officenet.no/~andreak/public_key.asc -BEGIN PGP SIGNA

Re: Upgrade question - was Re: [SQL] join and dynamic view

2002-12-17 Thread Andreas Joseph Krogh
1-5 > > over > > > christmas in fact. > > > > Will I need to dump/restore the database for this upgrade? As allways when version-upgrading(and not patch-level), you need to dump/restore as the binary on-disk format changes. - -- Andreas Joseph Krogh <[EMAIL PROTECTED]&

Re: [SQL] Need Postgresql Help

2002-12-02 Thread Andreas Joseph Krogh
w to create stored procedure in postgresql? > 2)How can i use it from perl script with parameters. ? > 3)How to return resultset from that Stored Procedure ? You need 7.3 to do 3). Infor on stored procedures: $INSTALLDIR/doc/html/plpgsql.html -- Andreas Joseph Krogh <[EM

[SQL] importing a 7.2 db with contrib/tsearch to 7.3

2002-11-21 Thread Andreas Joseph Krogh
n the table, the following error occures: e4u=> CREATE INDEX t_idx ON on_article_searchable USING gist (content); ERROR: data type txtidx has no default operator class for access method "gist" You must specify an operator class for the index or define a default operator

[SQL] Problems with to_char(created, 'WW')

2002-10-24 Thread Andreas Joseph Krogh
ek 43? -- Andreas Joseph Krogh <[EMAIL PROTECTED]> - There are 10 kinds of people in the world, those that can do binary arithmetic and those that can't. ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster

[SQL] 7.3 schemas

2002-09-27 Thread Andreas Joseph Krogh
d. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 6: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Stripping white-space in SELECT statments

2002-09-19 Thread Andreas Joseph Krogh
7; terminate its strings proparly and some random byte gets in the query. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Re: [SQL] Editor for pgsql

2002-07-23 Thread Andreas Joseph Krogh
ight now(on Mandrake-8.1 with KDE-3.0.2 ant qt-3.0.4) with the following options to configure: ./configure --without-oracle --without-kde make su -c "make install" This compiles and installes just fine to /usr/local/bin with PostgreSQL support. -- Andreas Joseph Krogh (Senior Software

Re: [SQL] graphical interface - admin

2002-07-01 Thread Andreas Joseph Krogh
On Monday 01 July 2002 15:00, Oleg Bartunov wrote: > On Mon, 1 Jul 2002, Andreas Joseph Krogh wrote: > > On Monday 01 July 2002 13:29, you wrote: > > > On Mon, 1 Jul 2002, Andreas Joseph Krogh wrote: > > > > Take a look at TOra - Toolkit For Oracle: >

Re: [SQL] graphical interface - admin

2002-07-01 Thread Andreas Joseph Krogh
On Monday 01 July 2002 13:29, you wrote: > On Mon, 1 Jul 2002, Andreas Joseph Krogh wrote: > > Take a look at TOra - Toolkit For Oracle: http://www.globecom.se/tora/ > > > > It has excellent PostgreSQL support. > > I tried 1.2.4 but didn't found how to configur

Re: [SQL] graphical interface - admin

2002-07-01 Thread Andreas Joseph Krogh
h Berkus Take a look at TOra - Toolkit For Oracle: http://www.globecom.se/tora/ It has excellent PostgreSQL support. -- Andreas Joseph Krogh (Senior Software Developer) <[EMAIL PROTECTED]> "Everything should be made as simple as possible, but not simpler" - Albert Einst

Re: [SQL] Trigger Problem

2001-09-20 Thread Andreas Joseph Krogh
es are sql,c,internal and > the created procedure languages. > > NOTE: > > I have studied in documenatation that only plpgsql > functions are written to be used in triggers. You need to issue: $ createlang plpgsql to create the plpgsql language on your database. -- Andreas Josep

Re: [SQL] RE: Referencing named attribute in where clause doesn't work with7.1.2?

2001-08-08 Thread Andreas Joseph Krogh
N on_text.lang_id = code.id AND code_group.description = 'lang' AND code.code_key = 'lang.NO') ON article.title_text_key = on_text.text_key WHERE on_text.text_value IS NOT NULL; And now it works! Thank you for helping me out. -- Andreas Joseph Krogh <[EMAIL PROTECTED]>

Re: [SQL] Referencing named attribute in where clause doesn't workwith 7.1.2?

2001-08-08 Thread Andreas Joseph Krogh
Thomas Good wrote: > > On Wed, 8 Aug 2001, Andreas Joseph Krogh wrote: > > > Hi, this is my first post to this list so please... > > I have problems getting this query to work, any ideas? > > > > select article.title_text_key, > > (selec

[SQL] Referencing named attribute in where clause doesn't work with 7.1.2?

2001-08-08 Thread Andreas Joseph Krogh
; ERROR: Attribute 'title_text_value' not found Issuing the same query without the where-clause does work tho, but return tupples with null in them which I don't want. -- Andreas Joseph Krogh <[EMAIL PROTECTED]> ---(end of broadcast)--- TIP 4: Don't 'kill -9' the postmaster